Is the following code correct in C ++? (*)
I find it difficult to determine where to even look in the standard, and a search on the Internet did not find anything specific.
struct S; struct T { constexpr T() = default; bool S::* a = nullptr; int b = 42; }; const T t{};
The reason I ask is because it works (or seems to be) with newer versions of GCC and Clang (x86 / x86_64), but with an error (**) with Visual Studio 2015 Update 2 and Update 3 RC .
Before reporting an error, I would like to make sure that I am not relying on undefined behavior or just not looking for the right conditions.
I also tried using /vmg and /vmb as indicated in this post .
(*): I mainly care about C ++ 14 and later, but I see no reason why the answer should not apply to C ++ 11.
(**): If the code is clearly defined, it looks like an error in the codec, where it is not the location of the pointer. Changing struct S to struct S{} seems like the code is "working."
c ++ c ++ 11 visual-c ++
user786653
source share