Bug 70254 - Compiler crash
Summary: Compiler crash
Status: RESOLVED DUPLICATE of bug 63693
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.9.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2016-03-16 09:30 UTC by Daniel
Modified: 2016-09-20 09:08 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 6.1.0, 7.0
Known to fail: 4.9.3, 5.4.0
Last reconfirmed: 2016-07-09 00:00:00


Attachments
test case (89 bytes, text/plain)
2016-03-16 18:59 UTC, Daniel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel 2016-03-16 09:30:25 UTC
g++ crashes with internal compiler error: Segmentation fault

when trying to instantiate the following template class:


template<typename Creator>
class NamedResourceFactory
{
    using ResourceType = decltype(Creator())::type::pointer;
};
Comment 1 Richard Biener 2016-03-16 10:10:11 UTC
Please provide a full testcase.
Comment 2 Daniel Krügler 2016-03-16 18:56:27 UTC
The following code:

//---------------
template<typename Creator>
class NamedResourceFactory
{
    using ResourceType = decltype(Creator())::type::pointer;
};

int main(){}
//---------------

compiled against gcc 4.9.0, 5.1.0, 5.2.0 results in the following output:

<quote>
prog.cc:4:26: internal compiler error: Segmentation fault
     using ResourceType = decltype(Creator())::type::pointer;
                          ^
0x94d21f crash_signal
	../../gcc-4.9.0/gcc/toplev.c:337
0x56c94a resolve_typename_type(tree_node*, bool)
	../../gcc-4.9.0/gcc/cp/pt.c:21385
0x5b1c01 cp_parser_nested_name_specifier_opt
	../../gcc-4.9.0/gcc/cp/parser.c:5188
0x5bcc13 cp_parser_id_expression
	../../gcc-4.9.0/gcc/cp/parser.c:4713
0x5bd5ff cp_parser_parse_and_diagnose_invalid_type_name
	../../gcc-4.9.0/gcc/cp/parser.c:3024
0x5aa3e7 cp_parser_type_specifier_seq
	../../gcc-4.9.0/gcc/cp/parser.c:18139
0x5ba452 cp_parser_type_id_1
	../../gcc-4.9.0/gcc/cp/parser.c:18000
0x5bf069 cp_parser_type_id
	../../gcc-4.9.0/gcc/cp/parser.c:18040
0x5bf069 cp_parser_alias_declaration
	../../gcc-4.9.0/gcc/cp/parser.c:16135
0x5a43a5 cp_parser_member_declaration
	../../gcc-4.9.0/gcc/cp/parser.c:20186
0x5a7f50 cp_parser_member_specification_opt
	../../gcc-4.9.0/gcc/cp/parser.c:20093
0x5a7f50 cp_parser_class_specifier_1
	../../gcc-4.9.0/gcc/cp/parser.c:19321
0x5a7f50 cp_parser_class_specifier
	../../gcc-4.9.0/gcc/cp/parser.c:19548
0x5a7f50 cp_parser_type_specifier
	../../gcc-4.9.0/gcc/cp/parser.c:14337
0x5be620 cp_parser_decl_specifier_seq
	../../gcc-4.9.0/gcc/cp/parser.c:11573
0x5c2d63 cp_parser_single_declaration
	../../gcc-4.9.0/gcc/cp/parser.c:23159
0x5c3224 cp_parser_template_declaration_after_export
	../../gcc-4.9.0/gcc/cp/parser.c:23035
0x5cb639 cp_parser_declaration
	../../gcc-4.9.0/gcc/cp/parser.c:10973
0x5ca1a8 cp_parser_declaration_seq_opt
	../../gcc-4.9.0/gcc/cp/parser.c:10895
0x5cb9aa cp_parser_translation_unit
	../../gcc-4.9.0/gcc/cp/parser.c:4030
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.

1

Finish
</quote>

The problem seems to be fixed in the current head (Tested: gcc HEAD 6.0.0 20160311 (experimental)), where the normal compiler diagnostics is produced:

<quote>
prog.cc:4:26: error: need 'typename' before 'typename decltype (Creator())::type::pointer' because 'typename decltype (Creator())::type' is a dependent scope
     using ResourceType = decltype(Creator())::type::pointer;
</quote>
Comment 3 Daniel 2016-03-16 18:59:58 UTC
Created attachment 37992 [details]
test case


g++ -m64 -g -Wall -Wextra -pipe -fvisibility=default -x c++ -std=c++14 -fPIC example.cpp

results in a crash
Comment 4 Andrew Pinski 2016-07-09 07:01:15 UTC
Provided a testcase a long time ago.
Comment 5 Martin Sebor 2016-08-04 16:33:36 UTC
The first revision that crashes is r208040 (gcc 4.9.0).  It was fixed in r227098 (gcc 6.0.0) to resolve bug 63693.  It seems this bug can be closed as a duplicate then, or what's the process here?
Comment 6 Paolo Carlini 2016-09-20 09:08:58 UTC
Dup.

*** This bug has been marked as a duplicate of bug 63693 ***