[Bug c/57612] add builtin to assert that expression does not have side effects

tromey at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Jan 17 16:05:00 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57612

--- Comment #4 from Tom Tromey <tromey at gcc dot gnu.org> ---
(In reply to H. Peter Anvin from comment #2)
> I would like to second this request, however, I would like to request that
> it issues a warning rather than an error.  It can always be promoted to an
> error via -Werror= or the equivalent pragma.

What's the use case for this?
It seems simpler to just not use this macro when you don't want the effect.

(In reply to felix from comment #3)
> Overlaps bug 6906. Under that ticket, I proposed adding a built-in that
> simply returns whether or not a given expression has side effects, simply by
> exposing TREE_SIDE_EFFECTS().

This seems the same to me, in that __builtin_assert_no_side_effects
could, I think, just be a static_assert using your builtin.


More information about the Gcc-bugs mailing list