Bug 33333

Summary: ICE with #pragma omp parallel for in try/catch statement
Product: gcc Reporter: Sebastian Steiger <steigers>
Component: middle-endAssignee: Jakub Jelinek <jakub>
Status: RESOLVED FIXED    
Severity: normal CC: dnovillo, gcc-bugs, reichelt
Priority: P3 Keywords: ice-on-valid-code, monitored, openmp
Version: 4.2.1   
Target Milestone: 4.3.0   
URL: http://gcc.gnu.org/ml/gcc-patches/2008-01/msg01152.html
Host: Target:
Build: Known to work: 4.3.0
Known to fail: 4.2.0 4.2.2 Last reconfirmed: 2008-01-24 16:37:11
Attachments: Source code which fails to compile
Preprocessed file

Description Sebastian Steiger 2007-09-07 14:40:25 UTC
Overview
=========
When compiling the simple file which is attached to this report, I get the following message suggesting that I report it here:

compiler_error.cc:18: internal compiler error: in lower_regimplify, at omp-low.c:4251

Steps to reproduce
====================
Compile the attached file compiler_error.cc:
g++-4.2.1 -c -Wall -fopenmp -save-temps -o compiler_error.o compiler_error.cc

Build Date & Platform
=====================
Red Hat Enterprise Linux AS release 4 (Nahant Update 5)
Linux 2.6.19.2 #8 SMP Mon Jun 25 2007 x86_64 GNU/Linux
gcc was configured with: .../gcc-4.2.1/configure --prefix=.../gcc-4.2.1 --program-suffix=-4.2.1 --enable-threads --enable-languages=c++,fortran

The bug shows up both with the RedHat gcc version AND the "official" version.

The bug does not occur when I compile the source using the portland compiler, for example.

Additional Information
======================
1. When I remove the try...catch statement, the problem is gone.
2. When I do not loop up to the class variable A::x but a constant (say, 1000), the problem is gone.
Comment 1 Sebastian Steiger 2007-09-07 14:41:24 UTC
Created attachment 14169 [details]
Source code which fails to compile
Comment 2 Sebastian Steiger 2007-09-07 14:42:10 UTC
Created attachment 14170 [details]
Preprocessed file
Comment 3 Volker Reichelt 2007-12-27 19:09:41 UTC
Confirmed. Shorter testcase (just compile with "-fopenmp"):

==================================
struct A
{
  int n;
  void foo();
};

void A::foo()
{
  try
  {
#pragma omp parallel for
    for (int i = 0; i < n; ++i)
      ;
  } catch(...) {}
}
==================================
Comment 4 Jakub Jelinek 2008-01-25 09:13:45 UTC
Subject: Bug 33333

Author: jakub
Date: Fri Jan 25 09:12:57 2008
New Revision: 131820

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131820
Log:
	PR middle-end/33333
	* gimplify.c (gimplify_omp_for): Gimplify OMP_FOR_PRE_BODY.

	* g++.dg/gomp/pr33333.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/gomp/pr33333.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/gimplify.c
    trunk/gcc/testsuite/ChangeLog

Comment 5 Jakub Jelinek 2008-01-25 10:03:41 UTC
Fixed on the trunk.