public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/21402] New: wrong-code with inlining and type-punned pointer
@ 2005-05-05 15:35 gcc at arbruijn dot dds dot nl
  2005-05-05 15:38 ` [Bug rtl-optimization/21402] " gcc at arbruijn dot dds dot nl
                   ` (10 more replies)
  0 siblings, 11 replies; 15+ messages in thread
From: gcc at arbruijn dot dds dot nl @ 2005-05-05 15:35 UTC (permalink / raw)
  To: gcc-bugs

The attached C source gives wrong output when compiled with inlined functions
(-O3 or -O2 -finline-functions) with gcc-4.1-20050501 or gcc-4.0.0. Compiling
gives the following warning twice:
dereferencing type-punned pointer will break strict-aliasing rules

The expected output is 0 0, the actual output is two large values. Without
inlined functions or with the unsigned char pointers changed to char pointers
the problem disappears.

There seem to be two problems. One seems to be using an uninitialised stack
value for the pointer which should be initialized to the empty string. The other
seems to be that a pointer (the p2 pointer in the findlast function in the first
inlined readlen call) is modified in a register and is not written back to the
stack before it is read from the stack (to calculate the return value).

On (RedHat modified) gcc 3.4 the output is 0 -1 (it has only the second problem)
and in the actual application there was no problem with gcc 3.3 and before.

-- 
           Summary: wrong-code with inlining and type-punned pointer
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gcc at arbruijn dot dds dot nl
                CC: gcc-bugs at gcc dot gnu dot org
 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=21402


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

end of thread, other threads:[~2005-06-05  9:21 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-05 15:35 [Bug rtl-optimization/21402] New: wrong-code with inlining and type-punned pointer gcc at arbruijn dot dds dot nl
2005-05-05 15:38 ` [Bug rtl-optimization/21402] " gcc at arbruijn dot dds dot nl
2005-05-05 16:13 ` pinskia at gcc dot gnu dot org
2005-05-05 17:20 ` schlie at comcast dot net
2005-05-05 18:41   ` Andrew Pinski
2005-05-05 18:41 ` pinskia at physics dot uc dot edu
2005-05-21 21:28 ` schlie at comcast dot net
2005-05-21 21:42   ` Gabriel Dos Reis
2005-05-21 21:42 ` gdr at integrable-solutions dot net
2005-05-21 22:28 ` schlie at comcast dot net
2005-05-21 22:32   ` Andrew Pinski
2005-05-21 22:32 ` pinskia at physics dot uc dot edu
2005-05-21 23:31 ` schlie at comcast dot net
2005-06-05  9:21 ` pinskia at gcc dot gnu dot org
2005-06-05  9:21 ` 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).