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

Alexandre Oliva aoliva@redhat.com
Thu May 16 03:54:00 GMT 2002


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, not that it's ill-formed, so I've
arranged for we to emit a warning and generate code that simply calls
the global delete operator, which is the best we can do.  Failing to
invoke a destructor, if there is one, falls into the
undefined-behavior umbrella.

This patch was tested on athlon-pc-linux-gnu, without regressions.  Ok
to install?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: cp-delete-incomplete.patch
Type: text/x-patch
Size: 8209 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20020516/38ee1403/attachment.bin>
-------------- next part --------------

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer


More information about the Gcc-patches mailing list