https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108439

            Bug ID: 108439
           Summary: incorrect optimization with -O2, -O3, -Os
           Product: gcc
           Version: 12.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: georgmueller at gmx dot net
  Target Milestone: ---

Created attachment 54292
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54292&action=edit
test case to trigger bug

When testing the crap8 (or crapwow) hashing funtion, we discovered a gcc
optimization problem with gcc from at least version 9.3.0 up to 12.2.1.

The attached program (t_crap8.c) miscompiles for -O2, -O3, -Os while testing
the crap8 hash function (same behavior with similar hash function crapwow,
which only has different parameters m and n in the hash function).

Implementation is, for example. available in the smhasher project.

The line "lb_key[0] = 0x1234;" gets ignored with -O2, -O3, -Os.

As described in the report, compiling with -fno-strict-aliasing solves the
problem, but the code is compiling correctly with clang at all optimization
levels and does not report an error.

Reply via email to