Bug 84540 - [7 Regression] ICE with alignas in variadic template
Summary: [7 Regression] ICE with alignas in variadic template
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.3.1
: P2 normal
Target Milestone: 8.0
Assignee: Paolo Carlini
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2018-02-24 11:08 UTC by Volker Reichelt
Modified: 2019-11-14 11:09 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 5.4.0, 8.0
Known to fail: 6.4.0, 7.3.0, 7.5.0
Last reconfirmed: 2018-02-24 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2018-02-24 11:08:44 UTC
The following valid code snippet triggers an ICE since GCC 6.1.0,
while it was accepted in GCC 5.2.0 - 5.4.0:

=================================================================
template<typename... T> struct alignas(alignof(T)...) A {};

A<> a;
=================================================================

bug.cc: In instantiation of 'struct A<>':
bug.cc:3:5:   required from here
bug.cc:1:55: internal compiler error: Segmentation fault
 template<typename... T> struct alignas(alignof(T)...) A {};
                                                       ^
0xeb1cef crash_signal
	../../gcc/gcc/toplev.c:325
0x97866d contains_struct_check(tree_node*, tree_node_structure_enum, char const*, int, char const*)
	../../gcc/gcc/tree.h:3245
0x97866d apply_late_template_attributes
	../../gcc/gcc/cp/pt.c:10318
0x989727 instantiate_class_template_1
	../../gcc/gcc/cp/pt.c:10550
0x989727 instantiate_class_template(tree_node*)
	../../gcc/gcc/cp/pt.c:10930
0x9ce93d complete_type(tree_node*)
	../../gcc/gcc/cp/typeck.c:136
0x87f5b7 start_decl_1(tree_node*, bool)
	../../gcc/gcc/cp/decl.c:5201
0x8a52ff start_decl(cp_declarator const*, cp_decl_specifier_seq*, int, tree_node*, tree_node*, tree_node**)
	../../gcc/gcc/cp/decl.c:5164
0x934a89 cp_parser_init_declarator
	../../gcc/gcc/cp/parser.c:19578
0x93c1c8 cp_parser_simple_declaration
	../../gcc/gcc/cp/parser.c:13044
0x93cfd8 cp_parser_block_declaration
	../../gcc/gcc/cp/parser.c:12869
0x940f32 cp_parser_declaration
	../../gcc/gcc/cp/parser.c:12767
0x941341 cp_parser_declaration_seq_opt
	../../gcc/gcc/cp/parser.c:12643
0x941634 cp_parser_translation_unit
	../../gcc/gcc/cp/parser.c:4559
0x941634 c_parse_file()
	../../gcc/gcc/cp/parser.c:38866
0xa3f966 c_common_parse_file()
	../../gcc/gcc/c-family/c-opts.c:1132
Please submit a full bug report, [etc.]

Btw, clang 6.0.0rc2 accepts the code.
Comment 1 Martin Sebor 2018-02-24 21:57:19 UTC
Confirmed.  Bisection points to r232701:

r232701 | jason | 2016-01-21 15:26:02 -0500 (Thu, 21 Jan 2016) | 5 lines

	PR c++/43407
	* decl.c (start_enum): Add attributes parameter.
	* parser.c (cp_parser_enum_specifier): Pass it.
	* pt.c (lookup_template_class_1): Pass it.
	* cp-tree.h: Adjust.
Comment 2 Paolo Carlini 2018-02-26 15:46:35 UTC
This is valid, and doesn't seem hard to fix.
Comment 3 paolo@gcc.gnu.org 2018-02-26 20:07:12 UTC
Author: paolo
Date: Mon Feb 26 20:06:40 2018
New Revision: 258012

URL: https://gcc.gnu.org/viewcvs?rev=258012&root=gcc&view=rev
Log:
/cp
2018-02-26  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/84540
	* pt.c (tsubst_attributes): Handle correctly tsubst_attribute
	returning NULL_TREE.
	(apply_late_template_attributes): Likewise.

/testsuite
2018-02-26  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/84540
	* g++.dg/cpp0x/alignas14.C: New.
	* g++.dg/cpp0x/alignas15.C: Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/alignas14.C
    trunk/gcc/testsuite/g++.dg/cpp0x/alignas15.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog
Comment 4 Paolo Carlini 2018-02-26 20:08:00 UTC
Fixed in trunk so far.
Comment 5 Jakub Jelinek 2018-10-26 10:09:24 UTC
GCC 6 branch is being closed
Comment 6 Richard Biener 2019-11-14 11:09:19 UTC
Fixed in GCC 8.