This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++: delete of incomplete type is undefined, not ill-formed


>>>>> "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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]