![](/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.