public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/39117]  New: missed strict-aliasing warning
@ 2009-02-06  2:28 bkoz at gcc dot gnu dot org
  2009-02-06 10:09 ` [Bug middle-end/39117] " rguenth at gcc dot gnu dot org
  2009-02-12 15:11 ` [Bug c/39117] " manu at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: bkoz at gcc dot gnu dot org @ 2009-02-06  2:28 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 861 bytes --]

>From this thread:
http://gcc.gnu.org/ml/gcc-patches/2009-02/msg00271.html

Compiling with -c -g -O2 -Wall from r143978, I only get one warning, but should
get two.

struct A 
{ 
  int j;
  int i; 
};

void foo()
{
  char buf[sizeof(struct A)];

  // warns
  ((struct A*)buf)->i = 1;

  // does not warn
  struct A* p = (struct A*) buf;
  p->i = 4;
}

Gives:
alias2.c: In function ‘void foo()’:
alias2.c:12: warning: dereferencing type-punned pointer will break
strict-aliasing rules


-- 
           Summary: missed strict-aliasing warning
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bkoz at gcc dot gnu dot org


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


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

* [Bug middle-end/39117] missed strict-aliasing warning
  2009-02-06  2:28 [Bug middle-end/39117] New: missed strict-aliasing warning bkoz at gcc dot gnu dot org
@ 2009-02-06 10:09 ` rguenth at gcc dot gnu dot org
  2009-02-12 15:11 ` [Bug c/39117] " manu at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-02-06 10:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2009-02-06 10:09 -------
You get a warning issued by the frontend for the first case.  The second case
is not warned because we didn't prune buf fron ps points-to set.  This is
because while A has an alias set of 2, buf has alias set zero.  And obviously
2 is a subset of zero (which is the only thing we can really test here), so
we don't prune buf (even though it is not valid to access buf via A *).

This is a limitation of the C frontend which does not allow more precise
representation of "lvalue of character type".


-- 


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


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

* [Bug c/39117] missed strict-aliasing warning
  2009-02-06  2:28 [Bug middle-end/39117] New: missed strict-aliasing warning bkoz at gcc dot gnu dot org
  2009-02-06 10:09 ` [Bug middle-end/39117] " rguenth at gcc dot gnu dot org
@ 2009-02-12 15:11 ` manu at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: manu at gcc dot gnu dot org @ 2009-02-12 15:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from manu at gcc dot gnu dot org  2009-02-12 15:11 -------
So this is a bug in the C front-end. In any case, it is either a bug or an
enhancement request. So confirmed.


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu dot org
             Status|UNCONFIRMED                 |NEW
          Component|middle-end                  |c
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-02-12 15:11:24
               date|                            |


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


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

end of thread, other threads:[~2009-02-12 15:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-06  2:28 [Bug middle-end/39117] New: missed strict-aliasing warning bkoz at gcc dot gnu dot org
2009-02-06 10:09 ` [Bug middle-end/39117] " rguenth at gcc dot gnu dot org
2009-02-12 15:11 ` [Bug c/39117] " manu 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).