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

2021-03-16 Thread equinox-gccbugs at diac24 dot net via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57612

David L.  changed:

   What|Removed |Added

 CC||equinox-gccbugs at diac24 dot 
net

--- Comment #5 from David L.  ---
I would like to "third" this request.  In my head I was thinking of a
"__builtin_warn_side_effects(x[, "extra warning text"])" that returns the value
of x, but if the parameter does not actually get evaluated a
"__builtin_pure_p(x)" test returning 0/1 works too I guess.

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

2020-01-17 Thread tromey at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57612

--- Comment #4 from Tom Tromey  ---
(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.

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

2020-01-16 Thread felix.von.s at posteo dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57612

felix  changed:

   What|Removed |Added

 CC||felix.von.s at posteo dot de

--- Comment #3 from felix  ---
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 more general built-in could also (partially) address
bug 79469, by allowing to define __builtin_assume as 

#define __builtin_assume(cond) do { \
if (__builtin_pure_p(cond)) \
if (!(cond)) \
__builtin_unreachable(); \
} while (0)

Partially, because e.g. if A has side effects, then with the definition above
__builtin_assume(A && B) would consider the whole condition to have side
effects as well, and therefore disregard it, even if B could potentially be
mined for optimisation opportunities.

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

2017-01-24 Thread hpa at zytor dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57612

H. Peter Anvin  changed:

   What|Removed |Added

 CC||hpa at zytor dot com

--- Comment #2 from H. Peter Anvin  ---
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.

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

2014-08-08 Thread tromey at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57612

--- Comment #1 from Tom Tromey  ---
You can see the thread here:

http://patchwork.ozlabs.org/patch/343858/

My proposed patch didn't handle C++, which seems like
something it probably should do.