Bug 84080 - [6/7/8 Regression] the compiler crashes when compiling the following sample file
Summary: [6/7/8 Regression] the compiler crashes when compiling the following sample file
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.2.1
: P2 normal
Target Milestone: 8.0
Assignee: Jason Merrill
URL:
Keywords: ice-on-invalid-code
: 59912 88543 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-01-28 02:21 UTC by Fabio Cannizzo
Modified: 2018-12-18 18:14 UTC (History)
8 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-01-29 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fabio Cannizzo 2018-01-28 02:21:22 UTC
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
Comment 1 Jakub Jelinek 2018-01-29 08:47:42 UTC
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.
Comment 2 Jason Merrill 2018-02-13 15:57:32 UTC
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
Comment 3 Jason Merrill 2018-02-13 15:57:45 UTC
Fixed to reject the deduction in GCC 8.  I've raised this testcase with the committee to see if we want to allow it.
Comment 4 Volker Reichelt 2018-02-16 19:03:18 UTC
*** Bug 59912 has been marked as a duplicate of this bug. ***
Comment 5 Jakub Jelinek 2018-12-18 18:14:31 UTC
*** Bug 88543 has been marked as a duplicate of this bug. ***