https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123455
Bug ID: 123455
Summary: wrong code at -Os with asm goto
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: jiangchangwu at smail dot nju.edu.cn
Target Milestone: ---
This code returns 139 at -Os and returns 0 at -O0/1/2/3:
void abort();
void b(int c) {
if (0 == c)
__asm__ goto("jmp *%0" ::"r"(&&a) : : a);
__asm__ goto("" : : : : d);
a:
__asm__ goto("" : : : : d);
d:
if (c)
abort();
}
int main() { b(0); }
Compiler Explorer: https://godbolt.org/z/r65n4jc5a