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

            Bug ID: 100601
           Summary: wrong code at -O1 on x86_64-linux-gnu
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This seems to be a recent regression.

[563] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/12.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--prefix=/local/suz-local/software/local/gcc-trunk --enable-languages=c,c++
--disable-werror --enable-multilib --with-system-zlib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210514 (experimental) [master revision
df18a1343dd:515cc33a922:40a2f88838e5119799649a74692cbf38d774b706] (GCC) 
[564] % 
[564] % gcctk -O0 small.c; ./a.out
[565] % gcc110 -O1 small.c; ./a.out
[566] % 
[566] % gcctk -O1 small.c
[567] % ./a.out
Segmentation fault
[568] % 
[568] % cat small.c
struct a {
  unsigned b : 10;
} const c;
int d;
static void i(const struct a f) {
  unsigned j = f.b;
  for (; d < 1; d++)
    if (f.b) {
      int g = f.b;
    }
}
int main() {
  i(c);
  return 0;
}

Reply via email to