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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-04-16
     Ever confirmed|0                           |1
           Severity|enhancement                 |normal

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Teodor Petrov from comment #1)
> BTW: Do someone has an explanation why this is allowed in the standard?

Because it's only a problem if the type has a non-trivial destructor or an
overloaded operator delete. For a type with a trivial destructor (such as a
POD) all that needs to be done is deallocate the memory.

The standard says:

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

Since the compiler can't know if an incomplete type has a trivial destructor or
not, it can only warn, not give a hard error. If you want to make it a hard
error in your own program you should be able to, so confirming.

Reply via email to