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

            Bug ID: 123529
           Summary: [16 Regression] ICE in discriminator_for_local_entity,
                    at cp/mangle.cc:2316
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jirehguo at tju dot edu.cn
  Target Milestone: ---

Compiler Explorer:  https://godbolt.org/z/78cMsdavW
The following c++ code crash gcc trunk but does not crash gcc 13,14 and 15.

Code:
```cpp
 template <int &T> void FuncTemplate() {}
template <typename T> struct Container {
public:
  static void Execute() {
    static int InternalVar = 43;
    FuncTemplate<InternalVar>();
  }
};

int main() { Container<char>::Execute; }
```

Stack dump:
```
<source>:1:24: internal compiler error: in discriminator_for_local_entity, at
cp/mangle.cc:2316
    1 | template <int &T> void FuncTemplate() {}
      |                        ^~~~~~~~~~~~
0x2924d48 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x2919b0b internal_error(char const*, ...)
        ???:0
0xb16bf2 fancy_abort(char const*, int, char const*)
        ???:0
0xc73f59 mangle_decl(tree_node*)
        ???:0
0x189c175 decl_assembler_name(tree_node*)
        ???:0
0xfa3861 symbol_table::finalize_compilation_unit()
        ???: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.
Compiler returned: 1
```

Reply via email to