[Bug gcov-profile/124777] New: [16 Regression] wrong code at -Os -fprofile-generate on x86_64-pc-linux-gnu

xintong.zhou1 at uwaterloo dot ca gcc-bugzilla@gcc.gnu.org
Sat Apr 4 02:08:25 GMT 2026


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

            Bug ID: 124777
           Summary: [16 Regression] wrong code at -Os -fprofile-generate
                    on x86_64-pc-linux-gnu
           Product: gcc
           Version: 16.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/4Gs5Mzb3v

$ 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/16.0.1/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 16.0.1 20260403 (experimental) (GCC) 
$
$
$ gcc-trunk -Os small.c && ./a.out
$ gcc-trunk -Os -fprofile-generate small.c && ./a.out
[1]    4154367 segmentation fault (core dumped)  ./a.out
$
$
$ cat small.c
int a;
char b;
void c() {
  for (; a;)
    ;
}
static short d(unsigned f) {
  switch (f - 58385)
  case 7150:
    c();
  for (; a; a++)
    ;
}
static short g(unsigned f, unsigned h, unsigned short i) {
  if (f || h)
    d(i);
}
static unsigned j(unsigned f, char h) { g(b, 1, h); }
int main() {
  char e = -1;
  j(0, e);
}


More information about the Gcc-bugs mailing list