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

            Bug ID: 128309
           Summary: wrong code with -fopenacc: a parallel loop over an
                    unsigned range above INT_MAX runs no iteration
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: openacc, wrong-code
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kyuwoncho18 at gmail dot com
  Target Milestone: ---
            Target: x86_64-pc-linux-gnu

#include <stdio.h>

int main(void)
{
  unsigned int x = 0;
#pragma acc parallel loop reduction(+:x)
  for (unsigned int i = 0; i < 0xffffffffu; i += 0xffffffffu)
    x++;
  printf("%u\n", x);
  return 0;
}

godbolt: https://godbolt.org/z/farsfj7Tf

The loop runs once (i = 0; the next value 0xffffffff ends it), so the program
must print 1, as it does without -fopenacc. With -fopenacc it prints 0 at -O0,
-O1, -O2, -O3 and -Os.

Reply via email to