public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/27417]  New: wrong code or aliasing violation with missed diagnostic?
@ 2006-05-04 10:47 pluto at agmk dot net
  2006-05-04 11:58 ` [Bug other/27417] " rguenth at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: pluto at agmk dot net @ 2006-05-04 10:47 UTC (permalink / raw)
  To: gcc-bugs

inline float quickBinaryToFloat( unsigned const& in )
{
        return reinterpret_cast< float const& >( in ) ;
}

float foo( unsigned x )
{
        unsigned y = ( x * 2 ) + 1;
        return quickBinaryToFloat( y );
}


[ wrong-code generated ]

$ i486-gnu-linux-g++ bin2float.cpp -Wall -O2 -c -fomit-frame-pointer -m32

00000000 <foo(unsigned int)>:
   0:   83 ec 10                sub    $0x10,%esp
   3:   d9 44 24 0c             flds   0xc(%esp)
   7:   83 c4 10                add    $0x10,%esp
   a:   c3                      ret

[ correct code generated ]

$ i486-gnu-linux-g++ bin2float.cpp -Wall -O2 -c -fomit-frame-pointer -m32 \
                                   -fno-strict-aliasing

00000000 <foo(unsigned int)>:
   0:   83 ec 10                sub    $0x10,%esp
   3:   8b 44 24 14             mov    0x14(%esp),%eax
   7:   8d 44 00 01             lea    0x1(%eax,%eax,1),%eax
   b:   89 44 24 0c             mov    %eax,0xc(%esp)
   f:   d9 44 24 0c             flds   0xc(%esp)
  13:   83 c4 10                add    $0x10,%esp
  16:   c3                      ret


-- 
           Summary: wrong code or aliasing violation with missed diagnostic?
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pluto at agmk dot net
 GCC build triplet: i486-linux
  GCC host triplet: i486-linux
GCC target triplet: i486-linux


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


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

* [Bug other/27417] wrong code or aliasing violation with missed diagnostic?
  2006-05-04 10:47 [Bug other/27417] New: wrong code or aliasing violation with missed diagnostic? pluto at agmk dot net
@ 2006-05-04 11:58 ` rguenth at gcc dot gnu dot org
  2006-05-04 12:08 ` pluto at agmk dot net
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-05-04 11:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2006-05-04 11:58 -------
This missed diagnostic is known, as enabling a warning here would cause too
much "false" positives.  But yes, you are violating strict-aliasing rules here.


-- 


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


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

* [Bug other/27417] wrong code or aliasing violation with missed diagnostic?
  2006-05-04 10:47 [Bug other/27417] New: wrong code or aliasing violation with missed diagnostic? pluto at agmk dot net
  2006-05-04 11:58 ` [Bug other/27417] " rguenth at gcc dot gnu dot org
@ 2006-05-04 12:08 ` pluto at agmk dot net
  2006-05-04 14:00 ` rguenth at gcc dot gnu dot org
  2006-05-05 15:10 ` pluto at agmk dot net
  3 siblings, 0 replies; 5+ messages in thread
From: pluto at agmk dot net @ 2006-05-04 12:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pluto at agmk dot net  2006-05-04 12:08 -------
(In reply to comment #1)
> This missed diagnostic is known, as enabling a warning here would cause too
> much "false" positives.

but what about -Wstrict-aliasing=2?
it doesn't report anything, so how can i check possible
violations with accepted false-positive level?


-- 

pluto at agmk dot net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug other/27417] wrong code or aliasing violation with missed diagnostic?
  2006-05-04 10:47 [Bug other/27417] New: wrong code or aliasing violation with missed diagnostic? pluto at agmk dot net
  2006-05-04 11:58 ` [Bug other/27417] " rguenth at gcc dot gnu dot org
  2006-05-04 12:08 ` pluto at agmk dot net
@ 2006-05-04 14:00 ` rguenth at gcc dot gnu dot org
  2006-05-05 15:10 ` pluto at agmk dot net
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-05-04 14:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2006-05-04 14:00 -------
You cannot.  Though you can try extending c-common.c:strict_aliasing_warning
and
cp/typeck.c:build_reinterpret_cast_1 to warn in this case.


-- 


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


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

* [Bug other/27417] wrong code or aliasing violation with missed diagnostic?
  2006-05-04 10:47 [Bug other/27417] New: wrong code or aliasing violation with missed diagnostic? pluto at agmk dot net
                   ` (2 preceding siblings ...)
  2006-05-04 14:00 ` rguenth at gcc dot gnu dot org
@ 2006-05-05 15:10 ` pluto at agmk dot net
  3 siblings, 0 replies; 5+ messages in thread
From: pluto at agmk dot net @ 2006-05-05 15:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pluto at agmk dot net  2006-05-05 15:10 -------
(In reply to comment #3)
> You cannot.  Though you can try extending c-common.c:strict_aliasing_warning
> and
> cp/typeck.c:build_reinterpret_cast_1 to warn in this case.

sorry, but i don't know compiler internals to do this.
btw, maybe we should collect in one PR examples of undetected
aliasing violations for future work on better detection?


-- 


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


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

end of thread, other threads:[~2006-05-05 15:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-04 10:47 [Bug other/27417] New: wrong code or aliasing violation with missed diagnostic? pluto at agmk dot net
2006-05-04 11:58 ` [Bug other/27417] " rguenth at gcc dot gnu dot org
2006-05-04 12:08 ` pluto at agmk dot net
2006-05-04 14:00 ` rguenth at gcc dot gnu dot org
2006-05-05 15:10 ` pluto at agmk dot net

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