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

            Bug ID: 126944
           Summary: Wrong code at -O2 on x86_64-pc-linux-gnu
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xintong.zhou1 at uwaterloo dot ca
  Target Milestone: ---

Compiler Explorer: https://godbolt.org/z/Ebf1W49aK

$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=/data/x27zhou/compiler-nightly/install/gcc/bin/gcc
COLLECT_LTO_WRAPPER=/data/x27zhou/compiler-nightly/install/gcc/bin/../libexec/gcc/x86_64-pc-linux-gnu/17.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /data/x27zhou/compiler-nightly/src/gcc/configure CC='ccache
clang' CXX='ccache clang++' --enable-checking=yes
--disable-bootstrap--disable-multilib --enable-languages=c,c++
--prefix=/data/x27zhou/compiler-nightly/install/gcc-new
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 17.0.0 20260819 (experimental) (GCC)
$
$ gcc-trunk -O0 small.c && ./a.out
$ gcc-trunk -O2 small.c && ./a.out
[1]    3432373 segmentation fault (core dumped)  ./a.out
$
$ cat small.c
int a[2];
long e, c = 5487617;
char f(long g) {
  int d = g, b = 2 + d;
  if (*(a + (2 + d + 119 - -1921431 + b + 1u)))
    while (f)
      ;
  return 0;
}
void h(long g) {
  e = (g - 9) / (g ? g : 1) / 4;
  f(e + g - -960777 + g);
}
void i(short g) { h(g - 931838); }
void j(unsigned char g) { i(g - 29154); }
void main() { j(c + 214); }
  • [Bug tree-optimization/1269... xintong.zhou1 at uwaterloo dot ca via Gcc-bugs

Reply via email to