Did Visual Studio 2015 3 update the break constructor attributes?

The following code is compiled in VS2015u2.

class Foo { public: [[deprecated]] Foo(std::string); Foo(); }; 

In VS2015u3, I get an error:

 C2416: attribute 'deprecated' cannot be applied in this context 

This works in GCC 5.2 and works in earlier versions of VS2015. Of course, the deprecated attribute did not actually raise a warning in VS2015, but this was not a serious problem.

I don’t understand how to apply attributes to constructors? Or is VS2015u3 broken in this regard?

+5
source share
1 answer

In short: yes.

This is a mistake in which deprecated allowed to apply to a definition, but not to a constructor declaration (other member functions seem to be exact). For instance. the following compiles in a clean way, and unlike Update 2, it behaves correctly (gives C4996 diagnostics ):

 class Foo { public: [[deprecated]] Foo(std::string) { } Foo() { } }; 

Send an MS Connect error report and send a link here with a link so that we can transfer it .: -]

+4
source

All Articles