https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123494
Bug ID: 123494
Summary: ICE Segmentation fault in groktypename when using
_Alignas within a cast expression with _BitInt
Product: gcc
Version: 15.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: 522024330006 at smail dot nju.edu.cn
Target Milestone: ---
Go back to gcc 14.1(assertions)
To reproduce: https://godbolt.org/z/bchv8b8ac
GCC crashes with a Segmentation fault when encountering an invalid use of
_Alignas inside a type cast, specifically when combined with the _BitInt type.
While the code is syntactically invalid according to the C standard (alignment
specifiers are not permitted in type names for casts), the compiler should
issue a standard error message instead of crashing.
```
int main() {
return (_BitInt(9)_Alignas(long double)(volatile void *));
}
```
Traceback:
```
<source>: In function 'main':
<source>:2:23: error: alignment specified for type name in cast
2 | return (_BitInt(9)_Alignas(long double)(volatile void *));
| ^~~~~~~~
<source>:2:62: error: expected expression before ';' token
2 | return (_BitInt(9)_Alignas(long double)(volatile void *));
| ^
Segmentation fault
0x25c4b08 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x25b98cb internal_error(char const*, ...)
???:0
0x26263f3 pretty_printer::format(text_info&)
???:0
0x25c4403
diagnostics::context::report_diagnostic(diagnostics::diagnostic_info*)
???:0
0x25c4b08 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x25b8cad error_at(unsigned long, char const*, ...)
???:0
0xa58f21 groktypename(c_type_name*, tree_node**, bool*)
???:0
0xa84c5f c_cast_expr(unsigned long, c_type_name*, tree_node*)
???:0
0xaebfd0 c_parse_file()
???:0
0xb6fcc9 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.
```