gcc 4.0 gives an error message for the following file:
struct X {
  void destroy_me() { X::~X(); }
};
This code is incorrect, so an error message is appropriate.  However, the error 
message isn't likely to be 
useful.  

The error message we get is:
foo.cc: In member function 'void X::destroy_me()':
foo.cc:2: error: '~X' is not a member of 'X'

But that's not the real problem.  Obviously ~X() is a member of X.  The real 
problem is that this is the 
wrong syntax for an explicit destructor invocation: the user should have 
written this->X::~X(), not X::
~X() by itself.

(See the formal grammar for postfix expressions in 5.2/1, and the discussion of 
pseudo-destructor 
calls in 5.2.4, to see why this code is incorrect.)

-- 
           Summary: Misleading error message for ill-formed explicit
                    destructor invocation
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: austern at apple dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: all
  GCC host triplet: all
GCC target triplet: all


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19243

Reply via email to