Im compiling using MSVC v141 with /std:c++17
.
constexpr const char* test(const char* foo) {
return foo + 1;
}
constexpr const char* bc = test("abc");
compiles just fine, whereas
constexpr const char* test(const char* foo) {
constexpr auto bar = foo;
return bar + 1;
}
constexpr const char* bc = test("abc");
Fails with:
error C2131: expression did not evaluate to a constant
failure was caused by a read of a variable outside its lifetime
note: see usage of 'foo'
Is this correct behaviour or a bug in MSVC?