![](/img/trans.png)
[英]C++: Why does this constexpr template function cause an internal error in VS2017?(In gcc is ok)
[英]constexpr errors; VS2017 C++ compiler regression?
刚刚安装了VS2017,声称自2015年以来已经拥有出色的C ++ 14支持(这是初步的)。 给我的一个使用constexpr
项目一个旋转,并注意到似乎是一些回归。
这段代码:
struct s
{
size_t i;
constexpr s(nullptr_t) noexcept : i(0) {}
};
static_assert(s(nullptr).i == 0, "!!");
在VS2015和Clang上编译没问题,但我在VS2017中遇到一个新错误:
error C2131: expression did not evaluate to a constant
note: failure was caused by unevaluable pointer value
note: while evaluating 's::s(&s{(null)})'
这段代码看起来不错吧? constexpr
是否意味着nullptr
有问题?
我很惊讶这个基本可能出现的回归,我怀疑我的代码一定有问题......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.