https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112296
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |NEW
Keywords|documentation |
CC| |jakub at gcc dot gnu.org
Assignee|rguenth at gcc dot gnu.org |unassigned at gcc dot
gnu.org
--- Comment #15 from Richard Biener <rguenth at gcc dot gnu.org> ---
I clarified the documentation. While in the particular case 'span.size ()'
doesn't have side-effects (well, I'm not 100% sure) in general function calls
are difficult to handle "delayed" while still allowing to discard side-effects.
Maybe the infrastructure we put in place for [[assume]] could help here by
treating __builtin_constant_p (expr) as
[["assume" (guard)]]
{
tem = expr;
guard = __builtin_constant_p (tem);
}
guard;
and lower it to
.ASSUME (&artificial_fn, args...);
but now with a return value that would become zero at the point we elide
.ASSUME unless we end up with a [1,1] range for the result?
That said, it's best to avoid relying on the side-effect removal, that is,
avoid having arguments with possible side-effects in __builtin_constant_p.