public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/45320]  New: Strict-aliasing misdetection
@ 2010-08-18 15:01 strikosn at gmail dot com
  2010-08-18 15:29 ` [Bug c/45320] " paolo dot carlini at oracle dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: strikosn at gmail dot com @ 2010-08-18 15:01 UTC (permalink / raw)
  To: gcc-bugs

The following code fails to detect breaking of strict-aliasing rules correctly:

#include <stdio.h>

int main()
{        
        int i;
        float A[20];

        for (i = 0; i < 20; i++)
        {                                                                       
                A[i] = i;
                unsigned int *p = (unsigned int *)&A[i];
                printf("%d\t%.24f\t0x%08x\n", i, A[i], *p);
        }

        return 0;
}

gcc only gives a warning when compiling with '-Wall -O1'. Yet, compiling with
'-Wall -fstrict-aliasing' seems to produce correct results, even though '-Wall
-O2' breaks the code.


-- 
           Summary: Strict-aliasing misdetection
           Product: gcc
           Version: 4.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: strikosn at gmail dot com
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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


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

* [Bug c/45320] Strict-aliasing misdetection
  2010-08-18 15:01 [Bug c/45320] New: Strict-aliasing misdetection strikosn at gmail dot com
@ 2010-08-18 15:29 ` paolo dot carlini at oracle dot com
  2010-08-18 16:11 ` rguenth at gcc dot gnu dot org
  2010-08-19  9:51 ` strikosn at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-08-18 15:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from paolo dot carlini at oracle dot com  2010-08-18 15:28 -------
In general terms, ins't true that the warnings produced at -O0 are often much
weaker than when optimizing? I don't see anything aliasing-specific here...


-- 


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


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

* [Bug c/45320] Strict-aliasing misdetection
  2010-08-18 15:01 [Bug c/45320] New: Strict-aliasing misdetection strikosn at gmail dot com
  2010-08-18 15:29 ` [Bug c/45320] " paolo dot carlini at oracle dot com
@ 2010-08-18 16:11 ` rguenth at gcc dot gnu dot org
  2010-08-19  9:51 ` strikosn at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-08-18 16:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2010-08-18 16:10 -------
At -O2 -Wstrict-aliasing=1 warns for me.  I can't reproduce warnings
with -O0 or with -O1 because at those levels strict-aliasing isn't enabled.


-- 


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


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

* [Bug c/45320] Strict-aliasing misdetection
  2010-08-18 15:01 [Bug c/45320] New: Strict-aliasing misdetection strikosn at gmail dot com
  2010-08-18 15:29 ` [Bug c/45320] " paolo dot carlini at oracle dot com
  2010-08-18 16:11 ` rguenth at gcc dot gnu dot org
@ 2010-08-19  9:51 ` strikosn at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: strikosn at gmail dot com @ 2010-08-19  9:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from strikosn at gmail dot com  2010-08-19 09:50 -------
Ok, I reviewed all cases and it seems that gcc always does the right thing. The
only problem left is that strict-aliasing warning Levels 2 and 3, of which
Level 3 is enabled by default, do not detect this particular case of
strict-aliasing, even though Level 1 detects it correctly.


-- 


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


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

end of thread, other threads:[~2010-08-19  9:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-18 15:01 [Bug c/45320] New: Strict-aliasing misdetection strikosn at gmail dot com
2010-08-18 15:29 ` [Bug c/45320] " paolo dot carlini at oracle dot com
2010-08-18 16:11 ` rguenth at gcc dot gnu dot org
2010-08-19  9:51 ` strikosn at gmail dot com

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