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

            Bug ID: 103103
           Summary: Incorrect integer optimization omits x < 0 comparison
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: k.melekhin at gmail dot com
  Target Milestone: ---

Created attachment 51739
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51739&action=edit
Simple test program + version info

On higher optimization levels O2,O3 the following code omits the "newsz < 0"
comparison, likely due to invalid optimization / assumtion that value will
never change and always be 0, however this is incorrect.

See attachment, shows very simple test to reproduce. Also my gcc version
included
in that file comment.

Gcc's output with -O0 is correct. Tested with other C compilers and they
generate correct output on any optimization level.

Reply via email to