Bug 48522 - [C++0x] decltype((object)) with templated classes crashes g++ 4.5.1.
Summary: [C++0x] decltype((object)) with templated classes crashes g++ 4.5.1.
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.5.1
: P3 normal
Target Milestone: 4.6.0
Assignee: Paolo Carlini
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2011-04-08 21:33 UTC by David Oliver
Modified: 2011-05-09 23:27 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work: 4.6.0, 4.7.0
Known to fail: 4.5.3
Last reconfirmed: 2011-05-09 23:22:32


Attachments
Preprocessed broken_decltype.cpp (618 bytes, application/octet-stream)
2011-04-08 21:33 UTC, David Oliver
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Oliver 2011-04-08 21:33:50 UTC
Created attachment 23933 [details]
Preprocessed broken_decltype.cpp

Hello All,

The following innocent-looking code crashes the compiler:

template <typename T>
struct Handle
{
    Handle(T& t);
};

template<class T>
struct Class {
    struct Struct {} data;
    void f();
    void g();
};

template<class T>
void Class<T>::f() {
    Handle< decltype((data)) > handle(data);
}

template<class T>
void Class<T>::g() {
    Handle< decltype((data)) > handle(data);
}

The command line and compiler output were:

g++ -std=g++0x broken_decltype.cpp (see attachment for detailed flags)

broken_decltype.cpp: In member function ‘void Class<T>::g()’:
broken_decltype.cpp:21:30: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate

This fails on multiple distributions including Linux 2.6.35.6-45.fc14.x86_64,
GNU C++ (GCC) version 4.5.1 20100924 (Red Hat 4.5.1-4) (x86_64-redhat-linux)
compiled by GNU C version 4.5.1 20100924 (Red Hat 4.5.1-4), GMP version 4.3.1, MPFR version 2.4.2, MPC version 0.8.1

Cheers!

David.
Comment 1 Jonathan Wakely 2011-04-08 22:27:28 UTC
seems to be fixed in 4.6
Comment 2 Paolo Carlini 2011-05-09 23:22:32 UTC
Indeed. I'm going to add the testcase to mainline and 4_6-branch and close the PR.
Comment 3 paolo@gcc.gnu.org 2011-05-09 23:24:04 UTC
Author: paolo
Date: Mon May  9 23:24:01 2011
New Revision: 173598

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=173598
Log:
2011-05-09  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/48522
	* g++.dg/cpp0x/pr48522.C: New.


Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/pr48522.C
Modified:
    trunk/gcc/testsuite/ChangeLog
Comment 4 paolo@gcc.gnu.org 2011-05-09 23:24:23 UTC
Author: paolo
Date: Mon May  9 23:24:21 2011
New Revision: 173599

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=173599
Log:
2011-05-09  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/48522
	* g++.dg/cpp0x/pr48522.C: New.


Added:
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/pr48522.C
Modified:
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
Comment 5 Paolo Carlini 2011-05-09 23:27:23 UTC
Done.