public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/57612] New: add builtin to assert that expression does not have side effects
@ 2013-06-14 16:19 tromey at gcc dot gnu.org
  2021-03-17  6:29 ` [Bug c/57612] " equinox-gccbugs at diac24 dot net
  0 siblings, 1 reply; 2+ messages in thread
From: tromey at gcc dot gnu.org @ 2013-06-14 16:19 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 57612
           Summary: add builtin to assert that expression does not have
                    side effects
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tromey at gcc dot gnu.org

It would sometimes be useful to be able to assert
that an expression does not have side effects.
For example, this would be very nice to have for
macros which expand their arguments more than once:

#define multi_expand(x)  __builtin_assert_no_side_effects(x) + (x)

Specifically, this builtin would check its argument and
give an error if the argument had an assignment or a call
to a function which is neither "const" nor "pure".
The builtin would evaluate to the value of its argument.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c/57612] add builtin to assert that expression does not have side effects
  2013-06-14 16:19 [Bug c/57612] New: add builtin to assert that expression does not have side effects tromey at gcc dot gnu.org
@ 2021-03-17  6:29 ` equinox-gccbugs at diac24 dot net
  0 siblings, 0 replies; 2+ messages in thread
From: equinox-gccbugs at diac24 dot net @ 2021-03-17  6:29 UTC (permalink / raw)
  To: gcc-bugs

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

David L. <equinox-gccbugs at diac24 dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |equinox-gccbugs at diac24 dot net

--- Comment #5 from David L. <equinox-gccbugs at diac24 dot net> ---
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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-17  6:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-14 16:19 [Bug c/57612] New: add builtin to assert that expression does not have side effects tromey at gcc dot gnu.org
2021-03-17  6:29 ` [Bug c/57612] " equinox-gccbugs at diac24 dot net

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).