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

            Bug ID: 119780
           Summary: [13/14/15 regression] wrong code at -O{1,s} : runtime
                    hang
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chopra.kavya04 at gmail dot com
  Target Milestone: ---

The compiler hangs at runtime with -O{1,s}. It works fine for -O3 and -O2
though. Godbolt link: https://godbolt.org/z/1nx9xGd3h


kchopra@ast-epyc5:~$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/local/home/kchopra/compilers/libexec/gcc/x86_64-pc-linux-gnu/15.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/local/home/kchopra/compilers/
--with-local-prefix=/local/home/kchopra/compilers/
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 15.0.1 20250408 (experimental) (GCC) 
kchopra@ast-epyc5:~$ gcc -O0 bug_4.c; timeout -s 9 3 ./a.out 
kchopra@ast-epyc5:~$ gcc -O1 bug_4.c; timeout -s 9 3 ./a.out 
Killed
kchopra@ast-epyc5:~$ gcc -Os bug_4.c; timeout -s 9 3 ./a.out 
Killed
kchopra@ast-epyc5:~$ gcc -O3 bug_4.c; timeout -s 9 3 ./a.out 
kchopra@ast-epyc5:~$ cat bug_4.c 
int a = 1;
int b = -2147483647;
int c ;
int main() {                      
    goto d;                      
    e:     
        a = 0;                      
    f:     
        if ( -2147483647 * a -2147483647 * c >= 0) goto g;    
    h:     
        goto i;                      
    d:     
        if (  b >= 0) goto e;                          
        goto j;                      
    i:     
        if (  c -2147483647 * a >= 0) goto h;
        goto d;                      
    j:     
        b = 7;
        goto f;                      
    g:     
}

Reply via email to