Presumably something changed in the C++ standard.
The documentation notes:
"This warning is not generated by Visual C++ compilers that support C++11."
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
In Visual Studio 2017 (15.9.11) I fail to get warning C4482 on the code below.
I also tried to set:
Any idea why it does not work?
// Trying also to force the warning as an error
#pragma warning(error : 4482)
class CA
{
enum COLOR
{
RED = 0
};
void foo()
{
COLOR c = CA::COLOR::RED; // Expecting warning C4482
c = COLOR::RED; // Expecting warning C4482
}
};
Presumably something changed in the C++ standard.
The documentation notes:
"This warning is not generated by Visual C++ compilers that support C++11."
It's valid, standard-conforming code, as of C++11 which added the following paragraph:
[basic.lookup.qual]/5 A name prefixed by a nested-name-specifier that nominates an enumeration type shall represent an enumerator of that enumeration.
To remove all doubt, there's a (non-normative) example in [dcl.enum]:
enum direction { left=’l’, right=’r’ };
void g() {
direction d; // OK
d = left; // OK
d = direction::right; // OK
}
enum class altitude { high=’h’, low=’l’ };
void h() {
altitude a; // OK
a = high; // error: high not in scope
a = altitude::low; // OK
}