https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123562
Bug ID: 123562
Summary: ICE: Segmentation fault in get_shorthand_constraints
with -std=c++20 flag
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/4sYbf43bf
The following c++ code crash gcc trunk with -std=c++20 flag.
Goes back to 12.1 with checking.
Code:
```cpp
export template <> const bool flag = false;
```
Stack dump:
```
<source>:1:1: warning: keyword 'export' is enabled with '-fmodules'
1 | export template <> const bool flag = false;
| ^~~~~~
<source>:1:18: error: invalid explicit specialization before '>' token
1 | export template <> const bool flag = false;
| ^
<source>:1:18: internal compiler error: Segmentation fault
0x2926688 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x291b44b internal_error(char const*, ...)
???:0
0xba1aea get_shorthand_constraints(tree_node*)
???:0
0xd57563 c_parse_file()
???:0
0xec8ee9 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.
Compiler returned: 1
```