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

            Bug ID: 122422
           Summary: Missing array size causes compiler crash
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: d7d1cd at mail dot ru
  Target Milestone: ---

If a static array is created in a class template without specifying the number
of elements, compiling a module with this template breaks the compiler (see
example here: https://godbolt.org/z/coTGc6354)

$ cat module.ixx
    export module M;
    template <typename> struct Type {
        constexpr static int arr[] = {42, 43, 44};
    };

$ g++ module.ixx -std=c++23 -fmodules-ts
    <source>:1:8: internal compiler error: in decl_value, at cp/module.cc:8293
    1 | export module M;
    | ^~~~~~ 
    0x28e2038 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind) 
    ???:0 
    0x28d6e2b internal_error(char const*, ...) 
    ???:0 
    0xb07b18 fancy_abort(char const*, int, char const*) 
    ???:0 
    0xca2945 depset::hash::find_dependencies(module_state*) 
    ???:0 
    0xca340a module_state::write_begin(elf_out*, cpp_reader*,
module_state_config&, unsigned int&) 
    ???:0
    0xca4c84 finish_module_processing(cpp_reader*)
    ???:0
    0xc215b2 c_parse_final_cleanups()
    ???:0
    0xeb1498 c_common_parse_file()
    ???:0

Explicitly specifying the size solves the problem
https://godbolt.org/z/ox9xTdWbM

Reply via email to