https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115589
Bug ID: 115589 Summary: (aarch64) clobbered register variables Product: gcc Version: 11.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: pietro.braione at gmail dot com Target Milestone: --- /* * compiled with gcc -O0, on my platform (Ubuntu 22.04 aarch64) prints: * * 4 * 2 * * This is a very simplified example. In my production code I have * variables that are assigned register x21-x23, and gcc generates * code that uses these registers as temporaries without saving * elsewhere the content of the variables, that are lost. */ #include <stdio.h> int a = 1, b = 1, c = 1, d = 1; void main() { register int x asm("x0"); x = 0; printf("%d\n", a + b + c + d); printf("%d\n", x); }