r/C_Programming • u/BugsOfBunnys • Sep 15 '26
Question OpenMP bug??
Hello, I know this is not exactly the place for this, but it is C code. I am writing a bit of C code to search a large space of numbers, but I noticed the loop never ran. I asked ChatGPT cause I thought I was going crazy, but found that this bottom example code does not run the loop.
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
int main() {
uint64_t count = 0;
#pragma omp parallel for schedule(dynamic) reduction(+ : count)
for (uint64_t n = 1; n < UINT64_MAX; ++n)
++count;
printf("%llu\n", (unsigned long long)count);
}
It noticed it breaks with the dynamic scheduler. If you use the default static it seems to work. Any ideas on what is happening?
View all comments
Show parent comment
2
u/tastygames_official Sep 15 '26
look again. That was exactly my point - I was GOING to reformat it like you said, but then realized what he wrote. Not sure if it was his intention or not, but that's what ended up happening. As we all figured out in this thread, it just runs for like 50 years.