public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug regression/40665]  New: dereferencing type-punned pointer warnings cannot be disabled
@ 2009-07-07  1:12 mikulas at artax dot karlin dot mff dot cuni dot cz
  2009-07-07  1:22 ` [Bug regression/40665] " mikulas at artax dot karlin dot mff dot cuni dot cz
                   ` (13 more replies)
  0 siblings, 14 replies; 17+ messages in thread
From: mikulas at artax dot karlin dot mff dot cuni dot cz @ 2009-07-07  1:12 UTC (permalink / raw)
  To: gcc-bugs

Gcc became recently (4.4) very bad regarding false positive type-punned
warnings. In previous versions, the warnings could be suppressed by casting to
(void *), in 3.x and 4.1 it worked perfectly, in 4.3 it still worked somehow
(except in -Wstrict-aliasing=3 mode), in 4.4 there are cases where it doesn't
work at all.

I don't want to completely disable the warnings with -Wno-strict-aliasing (this
could leave bugs unnotified), but I need a method to disable them on
case-by-case basis once I verified that the code in question is correct.

Simple example, compile with -O2 -Wall:

extern int c;
int a(void)
{
        return *(short *)(void *)&c;
}

In 4.4 the warning can't be disabled at all! The (void *) cast doesn't suppress
the warning and none of three options to -Wstrict-aliasing helps. In 4.3 the
cast to (void *) suppressed the warning in -Wstrict-aliasing 1,2 modes (and
didn't suppress it in the default mode 3), in 4.4 the warning can't be
suppressed at all.

Gcc developers tried to made these warnings more "intelligent" with less false
positives, but unfortunatelly they completely broke the method to disable them
in the specific case. For me, false positives are not a major problem --- when
I get a false positive, I just read the code, check it and if I conclude that
it's OK, I disable the warning with (void *).

But if there's no way to disable false positives, it makes the warnings
completely useless.


-- 
           Summary: dereferencing type-punned pointer warnings cannot be
                    disabled
           Product: gcc
           Version: 4.4.1
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: regression
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mikulas at artax dot karlin dot mff dot cuni dot cz
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

end of thread, other threads:[~2009-07-07 20:24 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-07  1:12 [Bug regression/40665] New: dereferencing type-punned pointer warnings cannot be disabled mikulas at artax dot karlin dot mff dot cuni dot cz
2009-07-07  1:22 ` [Bug regression/40665] " mikulas at artax dot karlin dot mff dot cuni dot cz
2009-07-07  1:34 ` mikulas at artax dot karlin dot mff dot cuni dot cz
2009-07-07  3:48   ` Andrew Pinski
2009-07-07  3:50   ` Andrew Pinski
2009-07-07  3:44 ` pinskia at gmail dot com
2009-07-07  3:44 ` [Bug regression/40665] New: " Andrew Pinski
2009-07-07  3:48 ` [Bug regression/40665] " pinskia at gmail dot com
2009-07-07  3:50 ` pinskia at gmail dot com
2009-07-07 10:25 ` manu at gcc dot gnu dot org
2009-07-07 16:32 ` mikulas at artax dot karlin dot mff dot cuni dot cz
2009-07-07 16:45 ` mikulas at artax dot karlin dot mff dot cuni dot cz
2009-07-07 16:55 ` pinskia at gcc dot gnu dot org
2009-07-07 18:08 ` mikulas at artax dot karlin dot mff dot cuni dot cz
2009-07-07 18:18 ` pinskia at gcc dot gnu dot org
2009-07-07 19:40 ` mikulas at artax dot karlin dot mff dot cuni dot cz
2009-07-07 20:24 ` pinskia at gcc dot gnu dot 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).