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

            Bug ID: 110954
           Summary: [14 Regression] Wrong code with -O0
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vsevolod.livinskiy at gmail dot com
  Target Milestone: ---

Link to the compiler explorer:
https://godbolt.org/z/WYoT4hW9v

Reproducer:
#include <stdio.h>
unsigned long long a;
void b(unsigned long long *c, int g) { *c = g; }
int d, e = -38921963;
long f;
int main() {
  d = (-1807546494482798067UL - f < (6033086967267 > 0)) & e |
      !(-1807546494482798067UL - f < (6033086967267 > 0));
  b(&a, d);
  printf("%llu\n", a);
  if (a != 1)
    __builtin_abort();
}

Error:
>$ g++ -O0 test.cpp && ./a.out 
18446744073670629653
Aborted (core dumped)
>$ /usr/bin/g++-11 -O0 test.cpp && ./a.out 
1

gcc version 14.0.0 20230808 (20659be04c2749f9f47b085f1789eee0d145fb36)

Reply via email to