簡體   English   中英

constexpr錯誤; VS2017 C ++編譯回歸?

[英]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有問題?
我很驚訝這個基本可能出現的回歸,我懷疑我的代碼一定有問題......

constexpr構造函數(std :: nullptr_t)導致“錯誤C2131:表達式未計算為常量”

此問題是Visual Studio 2017 15.1版中的錯誤報告
OP早先報道了另一個問題的變化(?)。

這已修復:Visual Studio 2017版本15.6預覽1

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM