Bug 102455 - ICE in verify_ctor_sanity with vector types in constexpr and variable template
Summary: ICE in verify_ctor_sanity with vector types in constexpr and variable template
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 12.0
: P3 normal
Target Milestone: ---
Assignee: Marek Polacek
URL:
Keywords: ice-on-invalid-code, ice-on-valid-code
Depends on:
Blocks: constexpr
  Show dependency treegraph
 
Reported: 2021-09-22 17:37 UTC by G. Steinmetz
Modified: 2025-02-17 17:38 UTC (History)
2 users (show)

See Also:
Host:
Target: x86_64-pc-linux-gnu
Build:
Known to work: 13.1.0
Known to fail:
Last reconfirmed: 2021-09-22 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description G. Steinmetz 2021-09-22 17:37:19 UTC
Affects versions down to at least r5 (with -std=c++14) :


$ cat z1.cc
typedef int v4si;
typedef float v4sf __attribute__ ((vector_size(4)));
constexpr v4sf foo (v4si) { for (;;) {} }
template <class> constexpr v4sf b = foo (v4si {});


$ g++-12-20210919 -c z1.cc
z1.cc:4:49: internal compiler error: in verify_ctor_sanity, at cp/constexpr.c:4451
    4 | template <class> constexpr v4sf b = foo (v4si {});
      |                                                 ^
0x6e1221 verify_ctor_sanity
        ../../gcc/cp/constexpr.c:4450
0x6ef919 cxx_eval_bare_aggregate
        ../../gcc/cp/constexpr.c:4493
0x6e5e73 cxx_eval_constant_expression
        ../../gcc/cp/constexpr.c:6793
0x6e353b cxx_bind_parameters_in_call
        ../../gcc/cp/constexpr.c:1644
0x6e353b cxx_eval_call_expression
        ../../gcc/cp/constexpr.c:2617
0x6e7174 cxx_eval_constant_expression
        ../../gcc/cp/constexpr.c:6336
0x6e5bb5 cxx_eval_constant_expression
        ../../gcc/cp/constexpr.c:6828
0x6e964b cxx_eval_outermost_constant_expr
        ../../gcc/cp/constexpr.c:7368
0x6ec82a fold_non_dependent_expr_template
        ../../gcc/cp/constexpr.c:7720
0x87abb4 store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, int)
        ../../gcc/cp/typeck2.c:777
0x73210d check_initializer
        ../../gcc/cp/decl.c:7277
0x734457 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
        ../../gcc/cp/decl.c:8077
0x7f3caf cp_parser_init_declarator
        ../../gcc/cp/parser.c:22665
0x7f6ba6 cp_parser_single_declaration
        ../../gcc/cp/parser.c:31569
0x7f6dc5 cp_parser_template_declaration_after_parameters
        ../../gcc/cp/parser.c:31134
0x7f758b cp_parser_explicit_template_declaration
        ../../gcc/cp/parser.c:31400
0x7f758b cp_parser_template_declaration_after_export
        ../../gcc/cp/parser.c:31419
0x7f97e9 cp_parser_declaration
        ../../gcc/cp/parser.c:14750
0x7fa4ab cp_parser_translation_unit
        ../../gcc/cp/parser.c:4978
0x7fa4ab c_parse_file()
        ../../gcc/cp/parser.c:47694
Comment 1 Drea Pinski 2021-09-22 18:06:34 UTC
The infinite loop is not needed:
typedef int v4si;
typedef float v4sf __attribute__ ((vector_size(4)));
constexpr v4sf foo (v4si a) { return (v4sf)a;}
template <class> constexpr v4sf b = foo (v4si {});
Comment 2 Drea Pinski 2023-08-11 22:12:18 UTC
Looks to be fixed for GCC 13.1.0.
Comment 3 Marek Polacek 2025-02-17 17:24:13 UTC
Got fixed by

commit d081807d8d70e3e87eae41e1560e54d503f4d465
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Dec 6 09:51:51 2022 -0500

    c++: avoid initializer_list<string> [PR105838]

I think we should have the Comment 1 test since the commit above added a different test.
Comment 4 GCC Commits 2025-02-17 17:37:17 UTC
The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:1787119229abca0c78f9c902eeb7c88efed37ce0

commit r15-7592-g1787119229abca0c78f9c902eeb7c88efed37ce0
Author: Marek Polacek <polacek@redhat.com>
Date:   Mon Feb 17 12:36:05 2025 -0500

    c++: add fixed test [PR102455]
    
    Fixed by r13-4564 but the tests are very different.
    
            PR c++/102455
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/ext/vector43.C: New test.
Comment 5 Marek Polacek 2025-02-17 17:38:00 UTC
Fixed.