public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/58114] New: allow turning the warning about deleting a pointer of incomplete type into an error
@ 2013-08-09 17:01 tilman.vogel at web dot de
  2014-04-16 15:28 ` [Bug c++/58114] " fuscated at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: tilman.vogel at web dot de @ 2013-08-09 17:01 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58114
           Summary: allow turning the warning about deleting a pointer of
                    incomplete type into an error
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tilman.vogel at web dot de

While many warning messages have a way to control their emission and treatment,
e.g. "warning: multi-line comment [-Wcomment]", some warnings do not, in
particular:

warning: possible problem detected in invocation of delete operator: [enabled
by default]
warning: 'value' has incomplete type [enabled by default]

As a consequence of being enabled by default, there does not seem to be an
associated warning class that I could pass to "-Werror=". 

I'd really like to be able to say 
"-Werror=delete-with-incomplete-type"


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/58114] allow turning the warning about deleting a pointer of incomplete type into an error
  2013-08-09 17:01 [Bug c++/58114] New: allow turning the warning about deleting a pointer of incomplete type into an error tilman.vogel at web dot de
@ 2014-04-16 15:28 ` fuscated at gmail dot com
  2014-04-16 16:39 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: fuscated at gmail dot com @ 2014-04-16 15:28 UTC (permalink / raw)
  To: gcc-bugs

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

Teodor Petrov <fuscated at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fuscated at gmail dot com

--- Comment #1 from Teodor Petrov <fuscated at gmail dot com> ---
This option is very important, because this warning allowed us to fix one
serious leak in our application. And to prevent this problem to reappear in the
future we want to force this warning to be error, but unfortunately we are not
able when building with GCC.

All other compilers we use have this feature. And btw in clang the option is
named -Wdelete-incomplete, so you can reuse it to minimize the difference
between the compilers.

BTW: Do someone has an explanation why this is allowed in the standard?


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/58114] allow turning the warning about deleting a pointer of incomplete type into an error
  2013-08-09 17:01 [Bug c++/58114] New: allow turning the warning about deleting a pointer of incomplete type into an error tilman.vogel at web dot de
  2014-04-16 15:28 ` [Bug c++/58114] " fuscated at gmail dot com
@ 2014-04-16 16:39 ` redi at gcc dot gnu.org
  2014-04-16 16:42 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2014-04-16 16:39 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/58114] allow turning the warning about deleting a pointer of incomplete type into an error
  2013-08-09 17:01 [Bug c++/58114] New: allow turning the warning about deleting a pointer of incomplete type into an error tilman.vogel at web dot de
  2014-04-16 15:28 ` [Bug c++/58114] " fuscated at gmail dot com
  2014-04-16 16:39 ` redi at gcc dot gnu.org
@ 2014-04-16 16:42 ` redi at gcc dot gnu.org
  2014-04-17 16:27 ` fuscated at gmail dot com
  2014-04-17 16:38 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2014-04-16 16:42 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE
   Target Milestone|---                         |4.9.0

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Actually it looks as though -Wdelete-incomplete is already supported

*** This bug has been marked as a duplicate of bug 43452 ***


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/58114] allow turning the warning about deleting a pointer of incomplete type into an error
  2013-08-09 17:01 [Bug c++/58114] New: allow turning the warning about deleting a pointer of incomplete type into an error tilman.vogel at web dot de
                   ` (2 preceding siblings ...)
  2014-04-16 16:42 ` redi at gcc dot gnu.org
@ 2014-04-17 16:27 ` fuscated at gmail dot com
  2014-04-17 16:38 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: fuscated at gmail dot com @ 2014-04-17 16:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Teodor Petrov <fuscated at gmail dot com> ---
@Jonathan Wakely: Do you think the ISO C++ standard people will be willing to
change this behaviour for a future standard? I'm asking in order to know if
there is any point in starting a conversation with them.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/58114] allow turning the warning about deleting a pointer of incomplete type into an error
  2013-08-09 17:01 [Bug c++/58114] New: allow turning the warning about deleting a pointer of incomplete type into an error tilman.vogel at web dot de
                   ` (3 preceding siblings ...)
  2014-04-17 16:27 ` fuscated at gmail dot com
@ 2014-04-17 16:38 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2014-04-17 16:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
That change would force compilers to reject currently valid programs that have
well-defined behaviour. Changes that like are not popular.

It is valid in C to pass a pointer to an incomplete type to free(), and this
C++ rule is compatible. You can delete incomplete types if they have trivial
destructors (like C structs).


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-04-17 16:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-09 17:01 [Bug c++/58114] New: allow turning the warning about deleting a pointer of incomplete type into an error tilman.vogel at web dot de
2014-04-16 15:28 ` [Bug c++/58114] " fuscated at gmail dot com
2014-04-16 16:39 ` redi at gcc dot gnu.org
2014-04-16 16:42 ` redi at gcc dot gnu.org
2014-04-17 16:27 ` fuscated at gmail dot com
2014-04-17 16:38 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).