https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82159
--- Comment #12 from chr at terma dot com --- I've build a gcc 7.2.0 + above patch using crosstool ng. The original test code passes, so I should have managed to succesfully create a patches gcc. Steps to Repro: ----------------- g++ -c -O0 testcase2.cpp testcase2.cpp: In constructor 'bd< <template-parameter-1-1> >::bg<bf>::bg(bd< <template-parameter-1-1> >::bb, bf) [with bf = l; <template-parameter-1-1> = bc<2, double>]': testcase2.cpp:37:31: internal compiler error: in assign_temp, at function.c:968 bg(bb, bf n) : bh(n.ap - 0) {} Source file testcase2.cpp: ------------- template <typename b> class d { b e; }; class f : d<int[0]> { public: f(const f &); }; class g : f { public: template <class h> g operator-(h); }; template <class ai> class i { public: typedef typename ai::template j<i> ak; }; template <class al> class k { typename i<al>::ak an; }; class l { public: g ap; }; class aq { public: ~aq(); }; template <class ar> class m : ar { public: template <typename at, typename au> m(at, au); l av; virtual void aw() { ar::ax(&av); } }; template <int, typename> class bc; template <class> class bd { public: typedef int bb; class be {}; template <class bf> class bg { public: g bh; bg(bb, bf n) : bh(n.ap - 0) {} }; bd(bb, be); }; template <typename> class o; template <int az, typename bl> class o<bd<bc<az, bl>>> : public bd<bc<az, bl>>::be {}; class L : bd<bc<2, double>> { class p : aq { public: void ax(l *p1) { bb a; bg<l>(a, *p1); } }; public: template <typename at, typename au> L(at p1, au n) : bd(p1, n) {} int br; virtual int bs() { m<p>(this, br); } }; template <typename> class q { o<bd<bc<2, double>>> bv; virtual L bw() { L(0, bv); } }; template <template <class> class by> class r { public: r() { by<int>(); } }; class s { public: template <class> class j : r<q> {}; }; void t() { k<s> c; } int main() { return 0; } Compiler used: ----------------- x86_64-corei7_avx-linux-gnu-g++ -v Using built-in specs. COLLECT_GCC=x86_64-corei7_avx-linux-gnu-g++ COLLECT_LTO_WRAPPER=/home/ries/work/build/tools/x86_64/gcc-7.2.0-glibc-2.25-x86_64/x86_64-corei7_avx-linux-gnu/libexec/gcc/x86_64-corei7_avx-linux-gnu/7.2.0/lto-wrapper Target: x86_64-corei7_avx-linux-gnu Configured with: /home/ries/work/build/tools/x86_64/gcc-7.2.0-glibc-2.25-x86_64/.build/x86_64-corei7_avx-linux-gnu/src/gcc/configure --build=x86_64-build_pc-linux-gnu --host=x86_64-build_pc-linux-gnu --target=x86_64-corei7_avx-linux-gnu --prefix=/home/ries/work/build/tools/x86_64/gcc-7.2.0-glibc-2.25-x86_64/x86_64-corei7_avx-linux-gnu --with-sysroot=/home/ries/work/build/tools/x86_64/gcc-7.2.0-glibc-2.25-x86_64/x86_64-corei7_avx-linux-gnu/x86_64-corei7_avx-linux-gnu/sysroot --enable-languages=c,c++ --with-arch=corei7-avx --with-tune=corei7-avx --with-pkgversion='crosstool-NG astrax_ASTRAX_902085-002_REL_A-2760-gc1aa3992abc-dirty' --enable-__cxa_atexit --disable-libmudflap --disable-libgomp --disable-libssp --disable-libquadmath --disable-libquadmath-support --disable-libsanitizer --enable-libmpx --with-gmp=/home/ries/work/build/tools/x86_64/gcc-7.2.0-glibc-2.25-x86_64/.build/x86_64-corei7_avx-linux-gnu/buildtools --with-mpfr=/home/ries/work/build/tools/x86_64/gcc-7.2.0-glibc-2.25-x86_64/.build/x86_64-corei7_avx-linux-gnu/buildtools --with-mpc=/home/ries/work/build/tools/x86_64/gcc-7.2.0-glibc-2.25-x86_64/.build/x86_64-corei7_avx-linux-gnu/buildtools --with-isl=/home/ries/work/build/tools/x86_64/gcc-7.2.0-glibc-2.25-x86_64/.build/x86_64-corei7_avx-linux-gnu/buildtools --enable-lto --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --enable-threads=posix --enable-target-optspace --disable-plugin --disable-nls --disable-multilib --with-local-prefix=/home/ries/work/build/tools/x86_64/gcc-7.2.0-glibc-2.25-x86_64/x86_64-corei7_avx-linux-gnu/x86_64-corei7_avx-linux-gnu/sysroot --enable-long-long Thread model: posix gcc version 7.2.0 (crosstool-NG gc1aa3992abc-dirty)