Illegal instruction when running a minimal OpenMP program

Viewed 1886

This minimal OpenMP program

#include <omp.h>
int main() 
{
  #pragma omp parallel sections
  {
    #pragma omp section
    {
      while(1) {}
    }

    #pragma omp section
    {  
      while(1) {}
    }
  }
}

will produce this error when compiled and run with gcc test.c -fopenmp:

Illegal instruction (core dumped)

When I change either one of the loops with

  int i=1;
  while(i++) {}

or any other condition it compiles and runs without error. It seems, that 1 as a loop condition in different threads cause some strange behaviour. Why?

edit: I am using gcc 4.6.3

edit: This is a bug in gcc and was submitted as Bug 54017 to the gcc developers.

2 Answers
Related