7

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?

0

1 Answer 1

5

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. :-]

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the confirmation and added detail. Bug report here: connect.microsoft.com/VisualStudio/feedback/details/2931827

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.