https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97883

            Bug ID: 97883
           Summary: [C++20] Segmentation fault on template<auto> with
                    braced initializer list A<{}>
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arthur.j.odwyer at gmail dot com
  Target Milestone: ---

// https://godbolt.org/z/841ahx
template<auto> struct A;
A<{}> a;

In -std=c++17 mode, this gives an error as expected. In -std=c++20 mode, this
segfaults:

<source>:2:5: error: deducing from brace-enclosed initializer list requires
'#include <initializer_list>'
  +++ |+#include <initializer_list>
    1 | template<auto> struct A;
    2 | A<{}> a;
      |     ^
<source>:2:5: internal compiler error: Segmentation fault
0x1bf9b89 internal_error(char const*, ...)
        ???:0
0x8a5846 do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int)
        ???:0
0x8c48ac lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
        ???:0
0x9197cd finish_template_type(tree_node*, tree_node*, int)
        ???:0
0x87f57c c_parse_file()
        ???:0
0x9f7452 c_common_parse_file()
        ???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.


If you "#include <initializer_list>", you successfully suppress the first error
message; but the segfault still happens in the same place.

Might be related to #95291 or #97749. It's weird that this happens ONLY in
C++20 mode, even though it uses nothing but C++17 features.
  • [Bug c++/97883] New: [C++20]... arthur.j.odwyer at gmail dot com via Gcc-bugs

Reply via email to