This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/49100] New: [OpenMP]: Compiler error when inline method defined within OpenMP loop
- From: "bisqwit at iki dot fi" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 21 May 2011 11:37:45 +0000
- Subject: [Bug c++/49100] New: [OpenMP]: Compiler error when inline method defined within OpenMP loop
- Auto-submitted: auto-generated
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.