In VS2015u2 the following code compiled fine.
class Foo {
public:
[[deprecated]] Foo(std::string);
Foo();
};
Under VS2015u3, I am getting an error:
C2416: attribute 'deprecated' cannot be applied in this context
This works in GCC 5.2 and it worked in earlier versions of VS2015. Granted, the deprecated attribute did not actually trigger a warning in VS2015, but that was not a significant concern.
Am I misunderstanding how to apply attributes to constructors? Or is VS2015u3 broken in this regard?
Microsoft announced the new release of Visual Studio 2015 Update 3 on June 27 2016. The Visual Studio team addressed the known issues and reported issues, which are fixed on this release as well as an improved performance and stability of the product. What’s new in Visual Studio 2015 Update 3?
But in Visual Studio 2015, the constructor and destructor aren't called. The compiler gives a warning about this behavior change. warning C4587: 'U::s': behavior change: constructor is no longer implicitly calledwarning C4588: 'U::s': behavior change: destructor is no longer implicitly called
This behavior is due to a regression in Visual Studio 2015 and Visual Studio 2015 Update 1; Visual Studio 2013 and previous versions of the compiler reject code written in this way. The behavior of Visual Studio 2015 and Visual Studio 2015 Update 1 is incorrect and doesn't conform to the C++ standard.
The behavior of Visual Studio 2015 and Visual Studio 2015 Update 1 is incorrect and doesn't conform to the C++ standard. Visual Studio 2015 Update 2 rejects code written in this way and issues compiler error C2511 instead.
To put it shortly: Yes.
This is a bug wherein deprecated
is allowed to be applied to the definition, but not to the declaration, of a constructor (other member functions seem fine). E.g. the following compiles cleanly, and unlike with Update 2, behaves correctly (yielding a C4996 diagnostic):
class Foo {
public:
[[deprecated]] Foo(std::string) { }
Foo() { }
};
Please submit a bug report to MS Connect and post back here with a link so that we may upvote it. :-]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With