Bug 27337 - OpenMP ICE in expand_expr_real_1 at expr.c:6814
Summary: OpenMP ICE in expand_expr_real_1 at expr.c:6814
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: ---
Assignee: Jakub Jelinek
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: openmp
Depends on:
Blocks:
 
Reported: 2006-04-27 12:10 UTC by Klaas
Modified: 2006-05-02 10:48 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-04-27 12:22:43


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Klaas 2006-04-27 12:10:17 UTC
Hi,

I have obtained an ICE in expand_expr_real_1, at expr.c:6814 when trying to build my code using OpenMP.  I am using gcc version "4.2.0 20060422 (experimental)" on target x86_64-unknown-linux-gnu.

The problem appears also in the FC5 gcc4.1.0 version "gcc (GCC) 4.1.0 20060304 (Red Hat 4.1.0-3)".

Below you find to pieces of code which produce the problem, as well as the output of gcc -v -save-temps.

The ICE disapears when removing all openmp directives and headerfiles.  The ICE disapears also when the function is a void instead of T1, and also if T1 is a normal 'old' type.

If you need more info, just contact me.
With kind regards,
Klaas

<BEGIN code.cpp>
#include "t1.h"
#include <omp.h>

T1 function (void) {
  int ii,N;
  T1 temp(N);

#pragma omp parallel for
  for (ii = 0; ii < N; ii++) {
    temp(ii,ii) = ii;
  }

  return temp;
}
<END code.cpp>

<BEGIN t1.h>
#ifndef LINALG_H
#define T1_H

class T1 {
 public :
  T1(int);
  ~T1(void);
  double &operator()(int, int) const;
 private :
  double *a;
};

#endif
<END t1.h>

[klaas@node13 src]$ /usr/local/gcc4.2/bin/x86_64-unknown-linux-gnu-g++ -v -save-temps -fopenmp -c code.cpp
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: /usr/local/src/gcc-4.2-20060422/configure --prefix=/usr/local/gcc4.2 --enable-languages=c,c++
Thread model: posix
gcc version 4.2.0 20060422 (experimental)
 /usr/local/gcc4.2/libexec/gcc/x86_64-unknown-linux-gnu/4.2.0/cc1plus -E -quiet -v -D_GNU_SOURCE -D_REENTRANT code.cpp -mtune=generic -fopenmp -fpch-preprocess -o code.ii
ignoring nonexistent directory "/usr/local/gcc4.2/lib/gcc/x86_64-unknown-linux-gnu/4.2.0/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/gcc4.2/lib/gcc/x86_64-unknown-linux-gnu/4.2.0/../../../../include/c++/4.2.0
 /usr/local/gcc4.2/lib/gcc/x86_64-unknown-linux-gnu/4.2.0/../../../../include/c++/4.2.0/x86_64-unknown-linux-gnu
 /usr/local/gcc4.2/lib/gcc/x86_64-unknown-linux-gnu/4.2.0/../../../../include/c++/4.2.0/backward
 /usr/local/include
 /usr/local/gcc4.2/include
 /usr/local/gcc4.2/lib/gcc/x86_64-unknown-linux-gnu/4.2.0/include
 /usr/include
End of search list.
 /usr/local/gcc4.2/libexec/gcc/x86_64-unknown-linux-gnu/4.2.0/cc1plus -fpreprocessed code.ii -quiet -dumpbase code.cpp -mtune=generic -auxbase code -version -fopenmp -o code.s
GNU C++ version 4.2.0 20060422 (experimental) (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.2.0 20060422 (experimental).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 99a2733c59c8f6d329de89f75af46282
code.cpp: In function âT1 function()â:
code.cpp:6: internal compiler error: in expand_expr_real_1, at expr.c:6814
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions
Comment 1 Klaas 2006-04-27 12:19:38 UTC
I forgot to state that in the FC5 version gcc (GCC) 4.1.0 20060304
(Red Hat 4.1.0-3) the ICE appears in expand_expr_real_1, at expr.c:6694.

Klaas
Comment 2 Jakub Jelinek 2006-04-27 12:22:43 UTC
OMP gimplification and lowering needs to handle RESULT_DECLs.
Simplified testcases e.g.:
struct S
{
  S ();
  ~S ();
  double &operator* () const;
};

S
foo ()
{
  int i;
  S ret;

#pragma omp parallel for
  for (i = 0; i < 2; i++)
    *ret += i;

  return ret;
}

or

struct S
{
  S ();
  ~S ();
  int i;
};

S
foo ()
{
  int i;
  S ret;

#pragma omp parallel for firstprivate (ret) lastprivate (ret)
  for (i = 0; i < 2; i++)
    ret.i += i;

  return ret;
}
Comment 3 Klaas 2006-04-27 13:09:01 UTC
The first test case gives me the same error when using the flags -fopenmp -c.  When I don't use -fopenmp, the code will compile.

The second test case gives me an other ICE.

code2.c: In function S foo():
code2.c:14: internal compiler error: tree check: expected tree that contains decl common structure, have indirect_ref  in omp_add_variable, at gimplify.c:4286

I don't know if this comment was usefull, or if these errors were obvious.

Greets
Klaas
Comment 4 Jakub Jelinek 2006-05-02 10:45:00 UTC
Subject: Bug 27337

Author: jakub
Date: Tue May  2 10:44:55 2006
New Revision: 113456

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113456
Log:
	PR middle-end/27337
	* gimplify.c (gimplify_scan_omp_clauses): Handle INDIRECT_REF
	around RESULT_DECL for result passed by reference.
	(gimplify_expr): Call omp_notice_variable when RESULT_DECL is seen.
	* omp-low.c (use_pointer_for_field): Don't look at
	DECL_HAS_VALUE_EXPR_P for RESULT_DECLs.
	(scan_omp_1): Call remap_decl on RESULT_DECLs.
	(lower_rec_input_clauses): Don't allocate VLA memory for the second
	time or var for passing by reference for
	OMP_CLAUSE_LASTPRIVATE_FIRSTPRIVATE clauses.  Allow creation of
	TREE_ADDRESSABLE variables when passing by reference.

	* omp-low.c (dump_omp_region): Fix output formatting.
cp/
	* cp-gimplify.c (cxx_omp_privatize_by_reference): New function.
	* cp-tree.h (cxx_omp_privatize_by_reference): New prototype.
	* cp-objcp-common.h (LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE): Define.
testsuite/
	* g++.dg/gomp/pr27337-1.C: New test.
	* g++.dg/gomp/pr27337-2.C: New test.
libgomp/
	* testsuite/libgomp.c++/pr27337.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/gomp/pr27337-1.C
    trunk/gcc/testsuite/g++.dg/gomp/pr27337-2.C
    trunk/libgomp/testsuite/libgomp.c++/pr27337.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-gimplify.c
    trunk/gcc/cp/cp-objcp-common.h
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/gimplify.c
    trunk/gcc/omp-low.c
    trunk/gcc/testsuite/ChangeLog
    trunk/libgomp/ChangeLog

Comment 5 Jakub Jelinek 2006-05-02 10:48:09 UTC
Fixed in SVN.