sharptooth
sharptooth

Reputation: 170499

What legal code could trigger C4523 "multiple destructors specified" Visual C++ warning?

According to MSDN, Visual C++ can emit C4523 warning 'class' : multiple destructors specified. How is such situation even possible?

I tried the following:

class Class {
    ~Class();
    ~Class(int);
};

which yields a destructor must have a 'void' parameter list error and C4523 warning and the following

class Class {
    ~Class();
    ~Class();
};

which yields member function already defined or declared error and the following

class Class {
    int ~Class();
    ~Class();
};

which yields a destructor cannot have a return type error.

So how do I have C4523 warning and no error?

Upvotes: 6

Views: 219

Answers (3)

Praetorian
Praetorian

Reputation: 109119

The following causes warning C4523 but it is also preceded by an error

struct Foo 
{
  ~Foo() {}
  ~Foo() const {}
};


error C2583: 'Foo::~Foo' : 'const' 'this' pointer is illegal for constructors/destructors
warning C4523: 'Foo' : multiple destructors specified

Upvotes: 3

Clafou
Clafou

Reputation: 15400

A wild guess: could it be through multiple class inheritance? Say if class C inherits from both class A and B, and A and B specify a destructor but C doesn't.

Upvotes: 0

Ben Voigt
Ben Voigt

Reputation: 283634

Here's another example of multiple destructors being an error, not a warning:

class C
{
    ~C();
    ~C() volatile;
};

Upvotes: 2

Related Questions