https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123358
Bug ID: 123358
Summary: ICE: in expand_asm_stmt, at cfgexpand.cc when using
enum constant with "m" constraint
Product: gcc
Version: 15.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: 522024330006 at smail dot nju.edu.cn
Target Milestone: ---
Reproducer: https://godbolt.org/z/c5enrYf9K
The compiler crashes (ICE) instead of issuing a regular error message when an
enumeration constant is passed to an inline asm statement using a memory
constraint ("m").
Program:
```c
namespace a {
enum { at = 5 };
}
void bar(void) {
__asm__("mov %1, %0" : : "m" (a::at));
}
```
Traceback:
```
internal compiler error: in expand_asm_stmt, at cfgexpand.cc:3763
8 | __asm__("mov %1, %0" : : "m" (a::at)); // Use of global enum value
inside asm
| ^~~~~~~
0x290fae8 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x29048ab internal_error(char const*, ...)
???:0
0xb12b52 fancy_abort(char const*, int, char const*)
???: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.
```