public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/39322] [4.4 regression] Bogus aliasing warning
  2009-02-27 22:20 [Bug middle-end/39322] New: [4.4 regression] Bogus aliasing warning reichelt at gcc dot gnu dot org
@ 2009-02-27 22:20 ` reichelt at gcc dot gnu dot org
  2009-02-27 22:24 ` [Bug middle-end/39322] " pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2009-02-27 22:20 UTC (permalink / raw)
  To: gcc-bugs



-- 

reichelt at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.4.0


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


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

* [Bug middle-end/39322]  New: [4.4 regression] Bogus aliasing warning
@ 2009-02-27 22:20 reichelt at gcc dot gnu dot org
  2009-02-27 22:20 ` [Bug middle-end/39322] " reichelt at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2009-02-27 22:20 UTC (permalink / raw)
  To: gcc-bugs

A IMHO the trunk issues a bogus warning for the following code snippet
when compiling it with "-O2 -Wall" using the C++ frontend:

==============================
int foo()
{
  char a[10];
  int i = *(int*)&a[4];
  int j = *(int*)(a+4);
  return i+j;
}
==============================

bug.cc: In function 'int foo()':
bug.cc:4: warning: dereferencing type-punned pointer will break strict-aliasing
rules

Interestingly, the warning is given only for line 4, but not line 5.
Also the C frontend is not affected.

If there's wrong alias info involved, this might lead to wrong-code bugs.


-- 
           Summary: [4.4 regression] Bogus aliasing warning
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: diagnostic, monitored
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: reichelt at gcc dot gnu dot org


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


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

* [Bug middle-end/39322] Bogus aliasing warning
  2009-02-27 22:20 [Bug middle-end/39322] New: [4.4 regression] Bogus aliasing warning reichelt at gcc dot gnu dot org
  2009-02-27 22:20 ` [Bug middle-end/39322] " reichelt at gcc dot gnu dot org
@ 2009-02-27 22:24 ` pinskia at gcc dot gnu dot org
  2009-02-27 22:24 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-02-27 22:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2009-02-27 22:23 -------
Actually this is not a bogus aliasing warning at all.  You are accessing a
character type as an int which is an aliasing violation.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.4 regression] Bogus      |Bogus aliasing warning
                   |aliasing warning            |


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


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

* [Bug middle-end/39322] Bogus aliasing warning
  2009-02-27 22:20 [Bug middle-end/39322] New: [4.4 regression] Bogus aliasing warning reichelt at gcc dot gnu dot org
  2009-02-27 22:20 ` [Bug middle-end/39322] " reichelt at gcc dot gnu dot org
  2009-02-27 22:24 ` [Bug middle-end/39322] " pinskia at gcc dot gnu dot org
@ 2009-02-27 22:24 ` pinskia at gcc dot gnu dot org
  2009-02-27 22:25 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-02-27 22:24 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.4.0                       |---


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


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

* [Bug middle-end/39322] Bogus aliasing warning
  2009-02-27 22:20 [Bug middle-end/39322] New: [4.4 regression] Bogus aliasing warning reichelt at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2009-02-27 22:24 ` pinskia at gcc dot gnu dot org
@ 2009-02-27 22:25 ` pinskia at gcc dot gnu dot org
  2009-02-27 22:37 ` [Bug middle-end/39322] Missed " rguenth at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-02-27 22:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2009-02-27 22:25 -------
We should give a warning on both lines.


-- 


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


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

* [Bug middle-end/39322] Missed aliasing warning
  2009-02-27 22:20 [Bug middle-end/39322] New: [4.4 regression] Bogus aliasing warning reichelt at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2009-02-27 22:25 ` pinskia at gcc dot gnu dot org
@ 2009-02-27 22:37 ` rguenth at gcc dot gnu dot org
  2009-02-27 22:52 ` pinskia at gcc dot gnu dot org
  2009-03-03 20:55 ` reichelt at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-02-27 22:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2009-02-27 22:37 -------
The FE warning code doesn't warn for *((int *) &a + 4) because it doesn't
recognize the form.  This is what we get in both cases from the C frontend
and in the second case from the C++ frontend.

The PTA warning code doesn't trigger here because we do not prune a from
the points-to sets.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-02-27 22:37:30
               date|                            |
            Summary|Bogus aliasing warning      |Missed aliasing warning


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


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

* [Bug middle-end/39322] Missed aliasing warning
  2009-02-27 22:20 [Bug middle-end/39322] New: [4.4 regression] Bogus aliasing warning reichelt at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2009-02-27 22:37 ` [Bug middle-end/39322] Missed " rguenth at gcc dot gnu dot org
@ 2009-02-27 22:52 ` pinskia at gcc dot gnu dot org
  2009-03-03 20:55 ` reichelt at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-02-27 22:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2009-02-27 22:52 -------
Related a little bit to bug 39117 or at least for the PTA side of things.


-- 


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


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

* [Bug middle-end/39322] Missed aliasing warning
  2009-02-27 22:20 [Bug middle-end/39322] New: [4.4 regression] Bogus aliasing warning reichelt at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2009-02-27 22:52 ` pinskia at gcc dot gnu dot org
@ 2009-03-03 20:55 ` reichelt at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2009-03-03 20:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from reichelt at gcc dot gnu dot org  2009-03-03 20:55 -------
> Actually this is not a bogus aliasing warning at all.  You are accessing a
> character type as an int which is an aliasing violation.

Yeah, you're right. One can only access an int array via a char pointer, but
not
the other way round. Sorry for screwing things up.


-- 


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


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

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

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-27 22:20 [Bug middle-end/39322] New: [4.4 regression] Bogus aliasing warning reichelt at gcc dot gnu dot org
2009-02-27 22:20 ` [Bug middle-end/39322] " reichelt at gcc dot gnu dot org
2009-02-27 22:24 ` [Bug middle-end/39322] " pinskia at gcc dot gnu dot org
2009-02-27 22:24 ` pinskia at gcc dot gnu dot org
2009-02-27 22:25 ` pinskia at gcc dot gnu dot org
2009-02-27 22:37 ` [Bug middle-end/39322] Missed " rguenth at gcc dot gnu dot org
2009-02-27 22:52 ` pinskia at gcc dot gnu dot org
2009-03-03 20:55 ` reichelt 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).