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

            Bug ID: 126302
           Summary: [16 Regression] Wrong code at -Os -fprofile-generate
                    on x86_64-pc-linux-gnu
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: gcov-profile
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xintong.zhou1 at uwaterloo dot ca
  Target Milestone: ---

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

$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/data/x27zhou/compiler-nightly/install/gcc/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
--enable-checking=yes --disable-bootstrap --disable-multilib
--enable-languages=c,c++ --prefix=/data/x27zhou/compiler-nightly/install/gcc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 17.0.0 20260717 (experimental) (GCC)
$
$ gcc-trunk -O3 small.c && ./a.out
$
$ gcc-trunk -Os small.c && ./a.out
$
$ gcc-trunk -Os -fprofile-generate small.c && ./a.out 
[1]    3004609 segmentation fault (core dumped)  ./a.out
$
$ cat small.c
short d, e, f;
int g;
static short(h)(short i) { return i == 0 || f % i; }
static int j(char i) {
  e = h(i);
  return d;
}
static void k(unsigned char i) {
  switch ((6 ^ 149121626 | 3 ^ 149121626) - 149121417)
  case 212:
    g = j(i);
}
int main() {
  int c = 212, a = 2135275220 - 2135275206;
  for (int b = 0; b < a; b += 4) {
    k(c);
    c = 0;
  }
}
  • [Bug gcov-profile/126302] N... xintong.zhou1 at uwaterloo dot ca via Gcc-bugs

Reply via email to