Consider the following C++14 (it's important) code:
struct B {
static constexpr int a = 1;
};
int main() {
auto p = &B::a;
}
Being compiled with gcc it leads to "undefined reference" since B::a
is not defined (just declared). To fix the issue we just have to define B::a
outside the struct:
constexpr int B::a;
But I have a problem with msvc compiler. Even without definition of B::a
the first code excerpt just compiled well (without an "undefined reference" issue).
Is there a way (I think a compiler option) to say msvc to detect such an issue being compiled for C++14 standard, i.e. when /std:c++14
option is used?
Here is the link to godbolt where I've tested the issue: https://godbolt.org/z/G8BnFY