This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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

           Summary: [OpenMP]: Compiler error when inline method defined
                    within OpenMP loop
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: bisqwit@iki.fi


This report is similar to PR49043, but unlike it, this does not involve C++0x.

This valid code fails to compile on GCC.
GCC spews an "invalid exit from OpenMP structured block" error message.

int main()
{
    #pragma omp parallel for
    for(int a=0; a<10; ++a)
    {
        struct x
        {
            void test() { return; };
        };
    }
}

If the explicit "return" statement is removed, it compiles.
It is also triggered by code such as this:

struct y
{
    static bool test(int c) { return c==5; }
};

if put inside the OpenMP loop construct, meaning it happens for static and
non-static methods as long as they include an explicit "return" statement.

The purpose of this error is to catch exits from an OpenMP construct (return,
break, goto). No such thing happens when a function is called or defined. The
error is not given when the struct is defined outside the loop (even if invoked
inside the loop). It is clearly a parser error.

It failed on all GCC versions that I tried that support OpenMP. These include
GCC 4.2.4, 4.3.5, 4.4.6, 4.5.3 and 4.6.1.

I have not tested whether the patch committed as a result of PR49043 also fixes
this bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]