https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112296
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|rguenth at gcc dot gnu.org |unassigned at gcc dot
gnu.org
Status|ASSIGNED |NEW
CC| |jason at gcc dot gnu.org,
| |rguenth at gcc dot gnu.org
--- Comment #11 from Richard Biener <rguenth at gcc dot gnu.org> ---
So as for the original description of this bug - it's a feature then (unless it
gets clarified in another way). Sorry. I agree it's highly unintuitive and I
would hope we can eventually add diagnostics for __builtin_constant_p with
arguments that have side-effects.
At least the documentation should be amended. Waiting for C/C++ frontend
maintainers to give an ACK, then I'll propose some wording for the
documentation.
Btw, clang also implements the weird semantics.
int g;
int bar () { if (!g) abort (); return 1; }
int main()
{
return __builtin_constant_p (bar());
}
returns 0 and doesn't abort().