简体   繁体   English

constexpr错误; VS2017 C ++编译回归?

[英]constexpr errors; VS2017 C++ compiler regression?

Just installed VS2017, which claims to have superior C++14 support since 2015 (which was rudimentary). 刚刚安装了VS2017,声称自2015年以来已经拥有出色的C ++ 14支持(这是初步的)。 Gave it a spin on one of my projects which uses constexpr , and noticed what appear to be some regressions. 给我的一个使用constexpr项目一个旋转,并注意到似乎是一些回归。

This code: 这段代码:

struct s
{
    size_t i;
    constexpr s(nullptr_t) noexcept : i(0) {}
};
static_assert(s(nullptr).i == 0, "!!");

Compiles no problem on VS2015 and Clang, but I get a new error in VS2017: 在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)})'

This code looks fine right? 这段代码看起来不错吧? Is constexpr meant to have a problem with nullptr ? constexpr是否意味着nullptr有问题?
I'm astonished a regression this basic could appear, I suspect there must be something wrong with my code... 我很惊讶这个基本可能出现的回归,我怀疑我的代码一定有问题......

constexpr constructor(std::nullptr_t) causes "error C2131: expression did not evaluate to a constant" constexpr构造函数(std :: nullptr_t)导致“错误C2131:表达式未计算为常量”

This issue was reported as a bug in Visual Studio 2017 version 15.1. 此问题是Visual Studio 2017 15.1版中的错误报告
There was a variation of another issue reported earlier by the OP (?). OP早先报道了另一个问题的变化(?)。

This was fixed in: Visual Studio 2017 version 15.6 Preview 1 这已修复:Visual Studio 2017版本15.6预览1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM