Bug 84798 - [6/7 Regression] ICE (Segmentation fault) if `auto` appears in a template argument
Summary: [6/7 Regression] ICE (Segmentation fault) if `auto` appears in a template arg...
Status: VERIFIED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.0.1
: P2 normal
Target Milestone: 7.4
Assignee: Jason Merrill
URL:
Keywords: ice-on-invalid-code
: 79525 84541 84840 (view as bug list)
Depends on:
Blocks: 84349 84647
  Show dependency treegraph
 
Reported: 2018-03-10 00:48 UTC by Vladimir Reshetnikov
Modified: 2018-08-14 21:36 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-03-12 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Reshetnikov 2018-03-10 00:48:55 UTC
The following C++ code causes an ICE in GCC 8.0.1 20180308 (tested with https://godbolt.org/):

/********************** SOURCE **********************/
template<typename T>
struct S {
    static constexpr T value = 0;
};

constexpr auto x = S<void(*)(auto)>::value;
/******************** END SOURCE ********************/


/********************** OUTPUT **********************/
<source>:6:38: internal compiler error: Segmentation fault
 constexpr auto x = S<void(*)(auto)>::value;
                                      ^~~~~
mmap: Invalid argument
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1
/******************** END OUTPUT ********************/

The same problem appears to exist in all versions since GCC 6.1.
Comment 1 Marek Polacek 2018-03-12 13:07:45 UTC
Confirmed.
Comment 2 Marek Polacek 2018-03-12 13:13:54 UTC
Started with r202540.  Before that:

error: parameter declared ‘auto’
 constexpr auto x = S<void(*)(auto)>::value;
                              ^
Comment 3 Jakub Jelinek 2018-03-12 13:23:50 UTC
Is auto valid among parameters except for generic lambdas?
Comment 4 Jakub Jelinek 2018-03-12 13:42:42 UTC
Outside of lambdas the patch essentially changed an error diagnostic to
                else if (cxx_dialect < cxx1y)
                  pedwarn (location_of (type), 0,
                      "use of %<auto%> in parameter declaration "
                      "only available with "
                      "-std=c++1y or -std=gnu++1y");
  	           else
  	             pedwarn (location_of (type), OPT_Wpedantic,
  	                      "ISO C++ forbids use of %<auto%> in parameter "
  	                      "declaration");
Do we really want that extension and what uses it?
Comment 5 Jason Merrill 2018-03-13 14:57:03 UTC
*** Bug 84840 has been marked as a duplicate of this bug. ***
Comment 6 Jason Merrill 2018-03-13 15:55:40 UTC
Author: jason
Date: Tue Mar 13 15:55:07 2018
New Revision: 258493

URL: https://gcc.gnu.org/viewcvs?rev=258493&root=gcc&view=rev
Log:
	PR c++/84798 - ICE with auto in abstract function declarator.

	* parser.c (cp_parser_parameter_declaration_clause): Check
	parser->default_arg_ok_p.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/auto51.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/g++.dg/cpp1y/pr60393.C
Comment 7 Volker Reichelt 2018-03-13 20:12:20 UTC
*** Bug 84541 has been marked as a duplicate of this bug. ***
Comment 8 Volker Reichelt 2018-03-13 20:16:06 UTC
*** Bug 79525 has been marked as a duplicate of this bug. ***
Comment 9 Jason Merrill 2018-03-23 14:40:06 UTC
Author: jason
Date: Fri Mar 23 14:39:30 2018
New Revision: 258809

URL: https://gcc.gnu.org/viewcvs?rev=258809&root=gcc&view=rev
Log:
	PR c++/84798 - ICE with auto in abstract function declarator.

	* parser.c (cp_parser_parameter_declaration_clause): Check
	parser->default_arg_ok_p.

Added:
    branches/gcc-7-branch/gcc/testsuite/g++.dg/cpp0x/auto-60626.C
    branches/gcc-7-branch/gcc/testsuite/g++.dg/cpp0x/auto51.C
Removed:
    branches/gcc-7-branch/gcc/testsuite/g++.dg/cpp1y/pr60626.C
Modified:
    branches/gcc-7-branch/gcc/cp/ChangeLog
    branches/gcc-7-branch/gcc/cp/parser.c
    branches/gcc-7-branch/gcc/testsuite/g++.dg/cpp1y/pr60393.C
Comment 10 Jason Merrill 2018-03-23 14:47:52 UTC
Fixed for 7.4/8.
Comment 11 Vladimir Reshetnikov 2018-08-14 21:36:43 UTC
Verified.