[Bug lto/97812] New: Wrong output when compiling the testcase with -O2 -flto

qiaopeixin at huawei dot com gcc-bugzilla@gcc.gnu.org
Thu Nov 12 12:19:38 GMT 2020


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

            Bug ID: 97812
           Summary: Wrong output when compiling the testcase with -O2
                    -flto
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: qiaopeixin at huawei dot com
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

Hi, gcc-trunk outputs wrong result when compiling the following testcase with
-O2 -flto:

#include<stdio.h>
short a;
volatile short b = 4066;
char c;
int main() {
  unsigned d = b & 2305;
  signed char e = d;
  c = e ? : e;
  if (d) {
    printf("%d\n", a);
  }
}

$gcc -O0 -w test.c && ./a.out
0

$gcc -O2 -flto -w test.c && ./a.out
(nothing)

gcc version 11.0.0 20201111 (experimental) (GCC)


More information about the Gcc-bugs mailing list