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

            Bug ID: 120766
           Summary: ICE Segmentation fault with duplicate extern variable
                    of template type
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rush102333 at gmail dot com
  Target Milestone: ---

Probably starts from gcc-12: https://godbolt.org/z/acEsfbn3j

Simplified Test:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

template<typename _Tp, typename _Bt = _Tp>
class RepPtrStore {
    _Tp * _obj;
    void foo();
};
template<typename _Tp,typename _Bt>
void RepPtrStore<_Tp,_Bt>::foo()
{
    extern _Tp * new_r;
    extern _Tp * new_r;
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Stack Dump:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

<source>: In member function 'void RepPtrStore<_Tp, _Bt>::foo()':
<source>:10:18: internal compiler error: Segmentation fault
   10 |     extern _Tp * new_r;
      |                  ^~~~~
0x283a3d5 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
        ???:0
0x285bb66 internal_error(char const*, ...)
        ???:0
0xdf3f3f merge_decl_attributes(tree_node*, tree_node*)
        ???:0
0xbbd06f duplicate_decls(tree_node*, tree_node*, bool, bool)
        ???:0
0xc9836f pushdecl(tree_node*, bool)
        ???:0
0xbcbd9d start_decl(cp_declarator const*, cp_decl_specifier_seq*, int,
tree_node*, tree_node*, tree_node**)
        ???:0
0xd07833 c_parse_file()
        ???:0
0xe6f319 c_common_parse_file()
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reply via email to