https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110174
Bug ID: 110174
Summary: Using illegal constraints for builtin return_address
gives ICE
Product: gcc
Version: 13.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: modula2
Assignee: gaius at gcc dot gnu.org
Reporter: [email protected]
Target Milestone: ---
When compiling the the following module with -O2
MODULE foo;
FROM Builtins IMPORT return_address;
FROM SYSTEM IMPORT ADDRESS;
VAR x: ADDRESS;
PROCEDURE test();
BEGIN
ASM VOLATILE("" : "=m"(x) : "m"(return_address(0)) : );
END test;
BEGIN
test();
END foo.
I get an ICE:
during RTL pass: expand
In function ‘test’,
inlined from ‘_M2_foo_init’ at foo.mod:13:3:
foo.mod:9:56: internal compiler error: in expand_asm_stmt, at cfgexpand.cc:3419
9 | ASM VOLATILE("" : "=m"(x) : "m"(return_address(0)) : );
| ^
The ICE is triggered at
https://github.com/gcc-mirror/gcc/blob/9589a46ddadc8b93c224c3f84fa94746c04596bf/gcc/cfgexpand.cc#L3419
Using "m" as constraint is actually wrong, however the C backend handles that
correctly:
foo.c:5:39: error: memory input 1 is not directly addressable
5 | __asm__ volatile("" : "=m"(x) : "m"(__builtin_return_address(0)) : );