The command # g++ -c prova.cpp -o prova.o prova.cpp:9:42: internal compiler error: Segmentation fault template <> auto foo<ca1>() { return a1; } ^ cause a g++ crash with the following input file: // prova.cpp enum aa {a1}; enum bb {b1}; enum cc {ca1, cb1}; template <cc n, typename T> T foo(); template <> auto foo<ca1>() { return a1; } template <> auto foo<cb1>() { return b1; } Tested on Linux Arch
Seems to ICE starting with r185768 when return type deduction has been added for -std=c++1y. The ICE in cgraph code, where we rely on being able to compute DECL_ASSEMBLER_NAME, but the mangling code refuses to give that, as it consider it dependent. Even the full name: "T foo() [with cc n = (cc)0; T = auto]" suggests that after deducing the return type we haven't updated the template parameter to what we've really deduced.
Author: jason Date: Tue Feb 13 15:57:00 2018 New Revision: 257630 URL: https://gcc.gnu.org/viewcvs?rev=257630&root=gcc&view=rev Log: PR c++/84080 - ICE with return type deduction and specialization. * pt.c (determine_specialization): Check uses_template_parms. Added: trunk/gcc/testsuite/g++.dg/cpp1y/auto-fn47.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/pt.c
Fixed to reject the deduction in GCC 8. I've raised this testcase with the committee to see if we want to allow it.
*** Bug 59912 has been marked as a duplicate of this bug. ***
*** Bug 88543 has been marked as a duplicate of this bug. ***