Bug 55032 - [4.7/4.8 Regression] Internal compiler error: in strip_typedefs, at cp/tree.c:1199
Summary: [4.7/4.8 Regression] Internal compiler error: in strip_typedefs, at cp/tree.c...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.2
: P2 normal
Target Milestone: 4.7.3
Assignee: Jason Merrill
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-23 11:05 UTC by Bruno De Fraine
Modified: 2013-01-02 19:04 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-10-24 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bruno De Fraine 2012-10-23 11:05:52 UTC
Some variations of bug #53989 still seem to exist (or gcc 4.7.2 does not contain a complete fix for that bug).

$ cat Test.cpp
template<typename T>
struct vec3t {
  T c[3];
};

typedef vec3t<float> vec3;

class Bounds {
  public:
    Bounds(const vec3 bb[2]);
    void foo(const vec3 & v) { v.c[0]; }
};

template<typename T>
void work(T& value);

void foo() {
  vec3 bb[2];
  work(bb);
}

$ g++ -Wall -c Test.cpp
Test.cpp: In member function 'void Bounds::foo(const vec3&)':
Test.cpp:11:38: warning: statement has no effect [-Wunused-value]
Test.cpp: In function 'void foo()':
Test.cpp:19:10: internal compiler error: in strip_typedefs, at cp/tree.c:1199
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/opt/gcc-4.7.2/libexec/gcc/x86_64-unknown-linux-gnu/4.7.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --prefix=/opt/gcc-4.7.2 --enable-languages=c,c++,fortran --disable-multilib
Thread model: posix
gcc version 4.7.2 (GCC)
Comment 1 Paolo Carlini 2012-10-24 14:05:53 UTC
Let's add Jason in CC about this. Besides PR53989, it seems also related to the following PR54038.
Comment 2 Jason Merrill 2012-12-06 20:20:46 UTC
Author: jason
Date: Thu Dec  6 20:20:34 2012
New Revision: 194265

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194265
Log:
	PR c++/55032
	* tree.c (build_array_type_1): Re-layout if we found it in the
	hash table.

Added:
    trunk/gcc/testsuite/g++.dg/template/array24.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree.c
Comment 3 Jason Merrill 2012-12-06 20:21:44 UTC
Author: jason
Date: Thu Dec  6 20:21:29 2012
New Revision: 194268

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194268
Log:
	PR c++/55032
	* tree.c (build_array_type_1): Re-layout if we found it in the
	hash table.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/g++.dg/template/array24.C
Modified:
    branches/gcc-4_7-branch/gcc/ChangeLog
    branches/gcc-4_7-branch/gcc/tree.c
Comment 4 Jason Merrill 2012-12-06 20:23:16 UTC
Fixed.
Comment 5 Jason Merrill 2012-12-07 04:58:56 UTC
Author: jason
Date: Fri Dec  7 04:58:45 2012
New Revision: 194286

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194286
Log:
	PR c++/55032
	* tree.c (build_array_type_1): Re-layout if we found it in the
	hash table.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/template/array24.C
Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/tree.c
Comment 6 Paul Pluzhnikov 2012-12-20 08:18:27 UTC
FYI, when we picked up r194286 into google/gcc-4_7 branch, and ran our 500,000 validation tests, we discovered two instances of mis-compilation.

This code:

  typedef vector<void*> T[13];

  void foo() {
    T x;
    ...
  }

is mis-compiled to omit 13 calls to vector::vector, and x[0], x[1], etc. all contain uninitialized stack garbage data members.

I've confirmed that trunk compiler is similarly broken.

Unfortunately I haven't been able to reduce the test case that exposes the problem yet.
Comment 7 Paul Pluzhnikov 2012-12-25 07:31:53 UTC
(In reply to comment #6)

> Unfortunately I haven't been able to reduce the test case that exposes the
> problem yet.

It took a whole week, but I finally have reduced test case in PR55804.
Comment 8 Jason Merrill 2013-01-02 19:03:19 UTC
Author: jason
Date: Wed Jan  2 19:03:04 2013
New Revision: 194811

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194811
Log:
	PR c++/55804
	PR c++/55032
	PR c++/55245
	* tree.c (build_array_type_1): Revert earlier change.
	* cp/tree.c (build_cplus_array_type): Copy layout information
	to main variant if necessary.

Added:
    trunk/gcc/testsuite/g++.dg/init/array33.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/tree.c
    trunk/gcc/tree.c
Comment 9 Jason Merrill 2013-01-02 19:03:55 UTC
Author: jason
Date: Wed Jan  2 19:03:37 2013
New Revision: 194812

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194812
Log:
	PR c++/55804
	PR c++/55032
	PR c++/55245
	* tree.c (build_array_type_1): Revert earlier change.
	* cp/tree.c (build_cplus_array_type): Copy layout information
	to main variant if necessary.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/g++.dg/init/array33.C
Modified:
    branches/gcc-4_7-branch/gcc/ChangeLog
    branches/gcc-4_7-branch/gcc/cp/ChangeLog
    branches/gcc-4_7-branch/gcc/cp/tree.c
    branches/gcc-4_7-branch/gcc/tree.c
Comment 10 Jason Merrill 2013-01-02 19:04:07 UTC
Author: jason
Date: Wed Jan  2 19:03:46 2013
New Revision: 194813

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194813
Log:
	PR c++/55804
	PR c++/55032
	PR c++/55245
	* tree.c (build_array_type_1): Revert earlier change.
	* cp/tree.c (build_cplus_array_type): Copy layout information
	to main variant if necessary.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/init/array33.C
Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/cp/ChangeLog
    branches/gcc-4_6-branch/gcc/cp/tree.c
    branches/gcc-4_6-branch/gcc/tree.c