[Bug c++/48522] New: decltype((object)) with templated classes crashes g++ 4.5.1.

david at rgmadvisors dot com gcc-bugzilla@gcc.gnu.org
Fri Apr 8 21:33:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48522

           Summary: decltype((object)) with templated classes crashes g++
                    4.5.1.
           Product: gcc
           Version: 4.5.1
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: david@rgmadvisors.com


Created attachment 23933
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23933
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.



More information about the Gcc-bugs mailing list