No, not at all.
I would say that this is the current limitation / error in MSVC2017, which may deserve to be recorded as an error report even if the attribute is also recognized in the case of an enumerator (and does not request warning C5030, as Mark pointed out in the comments to you question).
Application: which has now been verified (as a previously known bug) by the link provided by Hans Passant:
The C ++ 17 standard (working draft), [decl.attr.deprecated] , indicates:
Β§1 The deprecated token attribute can be used to mark names and entities whose use is still permitted, but the reason is not recommended.
Β§3 An attribute can be applied to a class declaration, and typedef-name, variable, non-static data member, function, namespace, enumeration, enumeration or pattern specialization ....
Using the /std:c++17 flag when compiling with MSVC2017, the deprecated attribute works for all of the above, but lists:
// a class class [[deprecated]] MyClass {}; // a typedef-name / type alias [[deprecated]] typedef int MyInt; using MyFloat [[deprecated]] = float; // a variable (see main) // a non-static data member struct DataMember { int b [[deprecated]]; }; // a function [[deprecated]] void myFunction() {} // a namespace namespace [[deprecated]] my_namespace { typedef double MyDouble; } // an enumeration enum [[deprecated]] MyEnum {}; // an enumeration enum MyNewEnum { val[[deprecated]] = 42 }; // a template specialization template <typename T> void myTemplateFunction(const T) {} template<> [[deprecated]] void myTemplateFunction<int>(const int) {} int main() { MyClass m; // warning C4996: 'MyClass': was declared deprecated MyInt i; // warning C4996: 'MyInt': was declared deprecated MyFloat f; // warning C4996: 'MyInt': was declared deprecated int j [[deprecated]]; j = 1; // warning C4996: 'j': was declared deprecated DataMember dm; dm.b = 1; // warning C4996: 'DataMember::b': was declared deprecated myFunction(); // warning C4996: 'myFunction': was declared deprecated my_namespace::MyDouble d; // warning C4996: 'my_namespace': was declared deprecated MyEnum e; // warning C4996: 'MyEnum': was declared deprecated myTemplateFunction(2); // warning C4996: 'myTemplateFunction': was declared deprecated MyNewEnum ne = val; // ... no warning return 0; }
Both gcc and clang cause failure warnings for MyNewEnum ne = val; above for -std=c++14 as well as -std=c++1z .
In a related note, especially the cppreference description of the deprecated attribute does not seem to have been updated with N4266, apart from the "enumerator" and "namespace" in valid usage declarations; although they are both present in the standard version of C ++ 14 (7.6.5 / 2) . This may be an indicator that this is a rarely used function (applied to counters / namespaces), which may explain why it was (partially) skipped in MVCS.
- Edit: A note about this has been added, and it has since been fixed.
Some ambiguity in the official MVSC documentation
Finally, the section in the MSVC docs does not actually contain details about what types of declarations the deprecated attribute is allowed on; showing only an example of rejecting a function declaration.
Although, as you pointed out (however, by reference to cppreference, and not in your own MSVC docs), MSVS2015 clearly indicates N4266 compliance , at least for C ++ 17.
Compiler functions
C ++ 17 Basic functions of the language
N4266 Attributes for namespaces and counters
Supported: VS2015
However, Support for C ++ 11/14/17 Features (Modern C ++) points to the opposite (for VS2015):
Compiler functions
C ++ 17 Suggested basic language features
N4266 Attributes for namespaces and counters
Supported VS2013: No
Supported VS2015: No