Bug 90750 - [9 Regression] ICE in cp_default_conversion, at cp/typeck.c:2162
Summary: [9 Regression] ICE in cp_default_conversion, at cp/typeck.c:2162
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 10.0
: P2 normal
Target Milestone: 9.4
Assignee: Jason Merrill
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2019-06-04 17:52 UTC by G. Steinmetz
Modified: 2020-04-28 15:54 UTC (History)
2 users (show)

See Also:
Host:
Target: x86_64-pc-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2019-06-04 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description G. Steinmetz 2019-06-04 17:52:31 UTC
Changed between 20190210 and 20190217 :


$ cat z1.cc
template <typename> struct S;
template <typename a> struct T
{
  using A = S<a>;
  using A::b;
  char* __attribute__((aligned(b))) c;
};


$ g++-10-20190602 -c z1.cc
z1.cc:6:37: internal compiler error: Segmentation fault
    6 |   char* __attribute__((aligned(b))) c;
      |                                     ^
0xb917ef crash_signal
        ../../gcc/toplev.c:326
0x733bce cp_default_conversion
        ../../gcc/cp/typeck.c:2162
0x79c064 common_handle_aligned_attribute
        ../../gcc/c-family/c-attribs.c:2006
0x7485f7 decl_attributes(tree_node**, tree_node*, int, tree_node*)
        ../../gcc/attribs.c:719
0x63bcac grokdeclarator(cp_declarator const*, cp_decl_specifier_seq*, decl_context, int, tree_node**)
        ../../gcc/cp/decl.c:11302
0x651d2d grokfield(cp_declarator const*, cp_decl_specifier_seq*, tree_node*, bool, tree_node*, tree_node*)
        ../../gcc/cp/decl2.c:823
0x6ca5e9 cp_parser_member_declaration
        ../../gcc/cp/parser.c:24774
0x6a831a cp_parser_member_specification_opt
        ../../gcc/cp/parser.c:24247
0x6a831a cp_parser_class_specifier_1
        ../../gcc/cp/parser.c:23388
0x6a9f11 cp_parser_class_specifier
        ../../gcc/cp/parser.c:23650
0x6a9f11 cp_parser_type_specifier
        ../../gcc/cp/parser.c:17412
0x6aaaf4 cp_parser_decl_specifier_seq
        ../../gcc/cp/parser.c:14108
0x6c88b5 cp_parser_single_declaration
        ../../gcc/cp/parser.c:28153
0x6c8c3c cp_parser_template_declaration_after_parameters
        ../../gcc/cp/parser.c:27834
0x6c9247 cp_parser_explicit_template_declaration
        ../../gcc/cp/parser.c:28082
0x6c9247 cp_parser_template_declaration_after_export
        ../../gcc/cp/parser.c:28101
0x6cbdb9 cp_parser_declaration
        ../../gcc/cp/parser.c:13171
0x6cc401 cp_parser_translation_unit
        ../../gcc/cp/parser.c:4690
0x6cc401 c_parse_file()
        ../../gcc/cp/parser.c:41176
0x78a7a0 c_common_parse_file()
        ../../gcc/c-family/c-opts.c:1156
Comment 1 Marek Polacek 2019-06-04 20:58:11 UTC
Started with r268851.
Comment 2 Jakub Jelinek 2019-08-12 08:58:09 UTC
GCC 9.2 has been released.
Comment 3 Jakub Jelinek 2020-03-12 11:58:57 UTC
GCC 9.3.0 has been released, adjusting target milestone.
Comment 4 GCC Commits 2020-04-27 21:22:01 UTC
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:5f1cd1da1a805c3d00332da45c3ab78a3931af63

commit r10-7998-g5f1cd1da1a805c3d00332da45c3ab78a3931af63
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Jan 27 05:45:01 2020 -0500

    c++: Avoid ICE with dependent attribute on type.
    
    We previously happened to accept this testcase, but never actually did
    anything useful with the attribute.  The patch for PR86379 stopped using
    TREE_TYPE as USING_DECL_SCOPE, so 'using A::b' no longer had TREE_TYPE set,
    so the language-independent decl_attributes started crashing on it.
    
    GNU attributes are more flexible in their placement than C++11 attributes,
    so if we encounter a dependent GNU attribute that syntactically appertains
    to a type rather than the declaration as a whole, move it to the
    declaration; that's almost certainly what the user meant, anyway.
    
    gcc/cp/ChangeLog
    2020-04-27  Jason Merrill  <jason@redhat.com>
    
            PR c++/90750
            PR c++/79585
            * decl.c (grokdeclarator): Move dependent attribute to decl.
            * decl2.c (splice_template_attributes): No longer static.
Comment 5 GCC Commits 2020-04-28 15:52:33 UTC
The releases/gcc-9 branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:aa988998be8f85334665a6b049d5d9139408c250

commit r9-8550-gaa988998be8f85334665a6b049d5d9139408c250
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Jan 27 05:45:01 2020 -0500

    c++: Avoid ICE with dependent attribute on type.
    
    We previously happened to accept this testcase, but never actually did
    anything useful with the attribute.  The patch for PR86379 stopped using
    TREE_TYPE as USING_DECL_SCOPE, so 'using A::b' no longer had TREE_TYPE set,
    so the language-independent decl_attributes started crashing on it.
    
    GNU attributes are more flexible in their placement than C++11 attributes,
    so if we encounter a dependent GNU attribute that syntactically appertains
    to a type rather than the declaration as a whole, move it to the
    declaration; that's almost certainly what the user meant, anyway.
    
    gcc/cp/ChangeLog
    2020-01-27  Jason Merrill  <jason@redhat.com>
    
            PR c++/90750
            PR c++/79585
            * decl.c (grokdeclarator): Move dependent attribute to decl.
            * decl2.c (splice_template_attributes): No longer static.
Comment 6 Jason Merrill 2020-04-28 15:54:28 UTC
Fixed for 9.4/10.