[Bug c++/49100] [OpenMP]: Compiler error when inline method defined within OpenMP loop

bisqwit at iki dot fi gcc-bugzilla@gcc.gnu.org
Sat May 21 12:01:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49100

--- Comment #1 from Joel Yliluoma <bisqwit at iki dot fi> 2011-05-21 11:31:46 UTC ---
It also does not happen with C's nested functions. This for instance compiles
and works just fine (to my surprise).

#include <stdio.h>
int main()
{
    int a;
    #pragma omp parallel for
    for(a=0; a<10; ++a)
    {
        int c() { return 65; }
        putchar( c() );
    }
    return 0;
}

I venture into another bug report here, but I wonder if this is a bug or
intentional behavior, that the code below outputs "YYYYYYYYYY", as though the
variable "a" within c() is bound to the a from the surrounding context rather
than the OpenMP loop's private copy of "a". If the OpenMP loop is removed, it
outputs "ABCDEFGHIJ" as expected.

#include <stdio.h>
int main()
{
    int a = 24;
    #pragma omp parallel for
    for(a=0; a<10; ++a)
    {
        int c() { return a+65; }
        putchar( c() );
    }
    return 0;
}



More information about the Gcc-bugs mailing list