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

--- Comment #2 from mattipee at yahoo dot co.uk 2012-04-18 09:32:16 UTC ---
The code was many hundreds of lines long, but I've stripped it down to fewer
than 40 lines with which I can reliably reproduce the ICE.


user@host:~$ g++ -v --save-temps -std=c++11 -Wall -c -o gcc53026.o gcc53026.cpp
Using built-in specs.
COLLECT_GCC=g++
Target: i686-pc-linux-gnu
Configured with: ../gcc-svn/configure : (reconfigured) ../gcc-svn/configure :
(reconfigured) ../gcc-svn/configure
--enable-languages=c,c++,fortran,java,lto,objc --no-create --no-recursion :
(reconfigured) ../gcc-svn/configure --enable-languages=c++ : (reconfigured)
../gcc-svn/configure --enable-languages=c,c++,lto --no-create --no-recursion :
(reconfigured) ../gcc-svn/configure --enable-languages=c,c++,lto --no-create
--no-recursion : (reconfigured) ../gcc-svn/configure
--enable-languages=c,c++,lto --no-create --no-recursion
Thread model: posix
gcc version 4.8.0 20120417 (experimental) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++11' '-Wall' '-c' '-o'
'gcc53026.o' '-shared-libgcc' '-mtune=generic' '-march=pentiumpro'
 /usr/local/libexec/gcc/i686-pc-linux-gnu/4.8.0/cc1plus -E -quiet -v
-D_GNU_SOURCE gcc53026.cpp -mtune=generic -march=pentiumpro -std=c++11 -Wall
-fpch-preprocess -o gcc53026.ii
ignoring nonexistent directory
"/usr/local/lib/gcc/i686-pc-linux-gnu/4.8.0/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/gcc/i686-pc-linux-gnu/4.8.0/../../../../include/c++/4.8.0

/usr/local/lib/gcc/i686-pc-linux-gnu/4.8.0/../../../../include/c++/4.8.0/i686-pc-linux-gnu

/usr/local/lib/gcc/i686-pc-linux-gnu/4.8.0/../../../../include/c++/4.8.0/backward
 /usr/local/lib/gcc/i686-pc-linux-gnu/4.8.0/include
 /usr/local/include
 /usr/local/lib/gcc/i686-pc-linux-gnu/4.8.0/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++11' '-Wall' '-c' '-o'
'gcc53026.o' '-shared-libgcc' '-mtune=generic' '-march=pentiumpro'
 /usr/local/libexec/gcc/i686-pc-linux-gnu/4.8.0/cc1plus -fpreprocessed
gcc53026.ii -quiet -dumpbase gcc53026.cpp -mtune=generic -march=pentiumpro
-auxbase-strip gcc53026.o -Wall -std=c++11 -version -o gcc53026.s
GNU C++ (GCC) version 4.8.0 20120417 (experimental) (i686-pc-linux-gnu)
    compiled by GNU C version 4.8.0 20120417 (experimental), GMP version 4.3.2,
MPFR version 3.0.0-p3, MPC version 0.8.2
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU C++ (GCC) version 4.8.0 20120417 (experimental) (i686-pc-linux-gnu)
    compiled by GNU C version 4.8.0 20120417 (experimental), GMP version 4.3.2,
MPFR version 3.0.0-p3, MPC version 0.8.2
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: d2533c0e8475a14a337438d44156a8a5
gcc53026.cpp: In instantiation of ‘struct Outer<const Inner<f()::Stub> >’:
gcc53026.cpp:37:13:   required from here
gcc53026.cpp:23:47: internal compiler error: Segmentation fault
     using MyInnerType = typename MyInner::type; // <--- !
                                               ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
user@host:~$ cat gcc53026.ii 
# 1 "gcc53026.cpp"
# 1 "<command-line>"
# 1 "gcc53026.cpp"

template<typename T>
struct Inner
{
    using type = T;
};


template<typename T>
struct Outer;

template<typename T>
struct Outer<Inner<T>>
{
    using MyInner = Inner<T>;
    using MyInnerType = typename MyInner::type;
};

template<typename T>
struct Outer<const Inner<T>>
{
    using MyInner = const Inner<T>;
    using MyInnerType = typename MyInner::type;
};


void f()
{
    struct Stub {};

    using I = Inner<Stub>;
    using O = Outer<I>;
    O o;

    using I_const = const Inner<Stub>;
    using O_const = Outer<I_const>;
    O_const o_const;

}
user@host:~$


"O o;" is ok, but "O_const o_const;" is not. However, it appears to work if
"using MyInner = const Inner<T>;" is replaced with "typedef const Inner<T>
MyInner;".


Sorry I haven't checked the behaviour of previous builds - it takes about an
hour per build on my machine.

Reply via email to