https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117469
Bug ID: 117469
Summary: returns_twice on defined functions
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: amonakov at gcc dot gnu.org
Target Milestone: ---
It is not really possible to define (not just declare) a returns_twice function
in C. The only possibilities I see are:
1) a "naked" function, on targets where that's supported;
2) a weak function, where the dummy definition returns normally, but the
link-time replacement (not written in C) really returns twice;
and there's a third alternative, which users could plausibly expect to work,
but we can not guarantee that:
3) the C code attempts to tail-call another function (which does return twice).
This third alternative is broken:
a) at -O0,
b) if sibcall transform fails for any reason,
c) if another function is not annotated with returns_twice (and our function is
inlined, for example).
I guess diagnostics for any of this is too much work, but extending our
documentation to reflect this could be reasonable.