Lambda返回值没有捕获

时间:2016-12-18 17:08:50

标签: c++ gcc lambda clang++ icc

这来自another question

以下程序在gcc和icc上编译,但无法在VS和clang上编译:

template <typename Y>
auto add_value(Y y)
{
    const short z{9};
    return [y](auto x)
    {
        return z;
    };
}

int main()
{
    add_value(2);
}

godbolt example 标志是:-std=c++14 -O2 -Wall -Wshadow -pedantic -pthread

哪个是对的?我想gcc在这里是正确的吗?但我更希望失败。

0 个答案:

没有答案
相关问题