Bug 89994 - [8 Regression] ICE (segfault) in compare_ics
Summary: [8 Regression] ICE (segfault) in compare_ics
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.3.1
: P3 normal
Target Milestone: 9.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2019-04-06 10:09 UTC by Matthias Klose
Modified: 2021-05-14 12:14 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 7.4.1, 9.0
Known to fail: 8.3.1
Last reconfirmed: 2019-04-08 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Klose 2019-04-06 10:09:33 UTC
$ cat test.ii
template <int, int, bool, class> class a;
namespace b {
template <typename, unsigned long, long, unsigned long, typename...> class b;
template <unsigned long, typename> struct c;
template <typename l, unsigned long d, unsigned long dim, typename... curshape>
struct c<d, b<l, dim, 0, dim, curshape...>> {
  using e = typename c<d - 1, b<l, dim, 0, dim, a<0, 1, true, void>>>::e;
};
template <typename l, unsigned long dim, typename... curshape>
struct c<0, b<l, dim, 0, dim, curshape...>> {
  using e = b<l, dim, 0, dim, curshape...>;
};
template <typename l, unsigned long f,
          template <int, int, bool, typename> class baseclass, int g, int h,
          typename i, typename... j>
class b<l, f, 0, f, baseclass<g, h, true, i>, j...> {
  b(long);
  b(const long (&)[]);
};
} // namespace b
template <long dim, typename l = double>
using blaspp = typename b::c<dim, b::b<l, dim, 0, dim>>::e;
blaspp<1> k({4})

$ g++ -c test.ii 
test.ii:23:16: internal compiler error: Segmentation fault
 blaspp<1> k({4})
                ^
0x8a0698 crash_signal
        ../../src/gcc/toplev.c:325
0x5aa51e compare_ics
        ../../src/gcc/cp/call.c:9684
0xe8cbe1 joust
        ../../src/gcc/cp/call.c:10124
0xe8a7f6 tourney
        ../../src/gcc/cp/call.c:10526
0xe8a7f6 build_new_method_call_1
        ../../src/gcc/cp/call.c:9295
0xe8a7f6 build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, tree_node*, int, tree_node**, int)
        ../../src/gcc/cp/call.c:9462
0xe8a7f6 build_special_member_call(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, tree_node*, int, int)
        ../../src/gcc/cp/call.c:8989
0xede19b expand_default_init
        ../../src/gcc/cp/init.c:1906
0xede19b expand_aggr_init_1
        ../../src/gcc/cp/init.c:2021
0xede19b build_aggr_init(tree_node*, tree_node*, int, int)
        ../../src/gcc/cp/init.c:1761
0xec44b8 build_aggr_init_full_exprs
        ../../src/gcc/cp/decl.c:6292
0xec44b8 check_initializer
        ../../src/gcc/cp/decl.c:6441
0xec2cbf cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
        ../../src/gcc/cp/decl.c:7154
0xf03597 cp_parser_init_declarator
        ../../src/gcc/cp/parser.c:19819
0xefec29 cp_parser_simple_declaration
        ../../src/gcc/cp/parser.c:13058
0xefe415 cp_parser_block_declaration
        ../../src/gcc/cp/parser.c:12877
0xefd737 cp_parser_declaration
        ../../src/gcc/cp/parser.c:12775
0xefd54a cp_parser_declaration_seq_opt
        ../../src/gcc/cp/parser.c:12651
0x14ba85b cp_parser_translation_unit
        ../../src/gcc/cp/parser.c:4563
0x14ba85b c_parse_file()
        ../../src/gcc/cp/parser.c:39118
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.

$ g++-7 -c test.ii 
test.ii:18:21: error: parameter '<anonymous>' includes reference to array of unknown bound 'const long int []'
   b(const long (&)[]);
                     ^
test.ii:23: confused by earlier errors, bailing out

$ g++-9 -c test.ii 
test.ii:23:16: error: call of overloaded 'b(<brace-enclosed initializer list>)' is ambiguous
   23 | blaspp<1> k({4})
      |                ^
test.ii:18:3: note: candidate: 'b::b<l, f, 0, f, baseclass<g, h, true, i>, j ...>::b(const long int (&)[]) [with l = double; long unsigned int f = 1; baseclass = a; int g = 0; int h = 1; i = void; j = {}]'
   18 |   b(const long (&)[]);
      |   ^
test.ii:17:3: note: candidate: 'b::b<l, f, 0, f, baseclass<g, h, true, i>, j ...>::b(long int) [with l = double; long unsigned int f = 1; baseclass = a; int g = 0; int h = 1; i = void; j = {}]'
   17 |   b(long);
      |   ^
test.ii:16:7: note: candidate: 'constexpr b::b<double, 1, 0, 1, a<0, 1, true, void> >::b(const b::b<double, 1, 0, 1, a<0, 1, true, void> >&)'
   16 | class b<l, f, 0, f, baseclass<g, h, true, i>, j...> {
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.ii:16:7: note: candidate: 'constexpr b::b<double, 1, 0, 1, a<0, 1, true, void> >::b(b::b<double, 1, 0, 1, a<0, 1, true, void> >&&)'
test.ii:23:16: error: expected ',' or ';' at end of input
   23 | blaspp<1> k({4})
      |                ^
Comment 1 Matthias Klose 2019-04-06 10:10:24 UTC
works on the gcc-7 branch and the trunk, ICEs on the gcc-8-branch.
Comment 2 Martin Liška 2019-04-08 07:27:20 UTC
It's rejected on trunk since r268606.
Comment 3 Martin Liška 2019-04-08 07:29:26 UTC
The ICE is much older that GCC-8:

  acafca510c97652f(09 Oct 2014 07:40): [took: 2.880s] result: OK
pr89994.cc:18:21: error: parameter ‘<anonymous>’ includes reference to array of unknown bound ‘const long int []’
   b(const long (&)[]);
                     ^
pr89994.cc:23:16: internal compiler error: Segmentation fault
 blaspp<1> k({4})
                ^
Comment 4 Jakub Jelinek 2020-03-04 09:39:14 UTC
GCC 8.4.0 has been released, adjusting target milestone.
Comment 5 Jakub Jelinek 2021-05-14 12:14:14 UTC
The GCC 8 branch is being closed, fixed in GCC 9.1.