I noticed this when building busybox 1.16.1, but I also saw this in other code:

When building with -O2 I get warnings like:
'warning: dereferencing type-punned pointer will break strict-aliasing rules'

The produced binary is broken, in the case of busybox, the 'sed' applet
segfaults.

When adding -fno-strict-aliasing, the warnings disappear, but the resulting
binary is still broken (with no warning or error indicating that something is
broken). The same also happens with -O1 or -Os, only a -O0 binary will work.

This used to work fine in gcc 4.4. I don't know how a test case would look
like, as I don't know the code that breaks that closely.

In my opinion, one of the following should happen:
a) gcc 4.5 should produce code that works
b) gcc 4.5 should throw a warning or error indicating that the code is
incorrect


-- 
           Summary: [4.5 regression] type-punning causes broken binaries
                    unless -O0 is used
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: critical
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: thomas at archlinux dot org
 GCC build triplet: x86_64-unknown-linux-gnu / i686-pc-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu / i686-pc-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu / i686-pc-linux-gnu


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

Reply via email to