This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++: delete of incomplete type is undefined, not ill-formed
- From: Jason Merrill <jason at redhat dot com>
- To: Gabriel Dos Reis <gdr at codesourcery dot com>
- Cc: Alexandre Oliva <aoliva at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Thu, 16 May 2002 12:40:21 +0100
- Subject: Re: C++: delete of incomplete type is undefined, not ill-formed
- References: <orvg9oo5rb.fsf@free.redhat.lsd.ic.unicamp.br><m3r8kcpcdp.fsf@merlin.nerim.net>
>>>>> "Gabriel" == Gabriel Dos Reis <gdr@codesourcery.com> writes:
> Alexandre Oliva <aoliva@redhat.com> writes:
> | [1 <text/plain>]
> | Once again, I'm not sure I can publish the testcase I got from the
> | customer, so I'll describe the problem. When we delete a variable
> | whose type is pointer-to-incomplete-type (say, a forward-declared
> | class type), we emit an error message. However, [expr.delete]/5 says
> | this invokes undefined behavior,
> I don't think it says exactly that. THere are the exact words:
> If the object being deleted has incomplete class type at the point
> of deletion *and* the complete class has a non-trivial destructor or a
> deallocation function, the behavior is undefined.
> (Emphasis is mine).
An important point. In fact, this is why Alex's patch is correct; if the
standard were as he represented it, we could always see that we were
invoking undefined behavior, and so the error would be the most useful
response. But we don't know whether or not the complete class will have
one of these functions, so we have to settle for a warning.
Alex: OK for trunk.
Jason