https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122835
Bug ID: 122835
Summary: cleanup function is not called with ASM GOTO in auto
cleanup scope
Product: gcc
Version: 15.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: ubizjak at gmail dot com
Target Milestone: ---
This came up recently on LKML [1]:
[1] https://lore.kernel.org/all/[email protected]/
The following testcase:
--cut here--
extern void exit (int);
static void my_cleanup (int *p)
{
exit (0);
}
int main ()
{
{
int foo __attribute__((cleanup (my_cleanup))) = 0;
asm goto("jmp %l0" :::: after);
}
after:
__builtin_abort ();
}
--cut here--
fails to call cleanup function when jumping out of auto cleanup scope with ASM
GOTO.
The testcase works OK when:
asm goto("jmp %l0" :::: after);
is substituted with plain:
goto after;