This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/58114] allow turning the warning about deleting a pointer of incomplete type into an error
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 16 Apr 2014 16:39:19 +0000
- Subject: [Bug c++/58114] allow turning the warning about deleting a pointer of incomplete type into an error
- Auto-submitted: auto-generated
- References: <bug-58114-4 at http dot gcc dot gnu dot org/bugzilla/>
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.