This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/72835] New: [Regression 7] Incorrect arithmetic optimization involving bitfield arguments


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

            Bug ID: 72835
           Summary: [Regression 7] Incorrect arithmetic optimization
                    involving bitfield arguments
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: babokin at gmail dot com
  Target Milestone: ---

Created attachment 39074
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=39074&action=edit
reproducer

-O0 and -O2 produce different results, while the test doesn't contain undefined
behavior.

> g++ -O0 bit_field_math.cpp ; ./a.out
4098873984
> g++ -O2 bit_field_math.cpp ; ./a.out
0
> g++ --version
gcc (Revision=238966/svn-rev:238969/) 7.0.0 20160801 (experimental)

GCC version 6 works correctly.

The test case is attached.

One thing that might look suspicious in the test is negation of unsigned int.
But it's well defined in the standard (same bit pattern as if it's signed, but
the result is treated as unsigned).

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]