[Bug c/6906] warn about asserts with side effects

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

felix  changed:

   What|Removed |Added

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

--- Comment #9 from felix  ---
I have just realised that __builtin_pure_p is already expressible:

#define __builtin_pure_p(expr) \
(__builtin_object_size(((void)(expr), ""), 2))

If (expr) is free of side effects, this is the same as
__builtin_object_size("", 2), which is 1. Otherwise, the expression returns 0.
This is documented behaviour, by the way. The documentation for
__builtin_object_size at
 states:

> __builtin_object_size never evaluates its arguments for side effects.
> If there are any side effects in them, it returns (size_t) -1 for
> type 0 or 1 and (size_t) 0 for type 2 or 3.

Experimentation reveals __attribute__((pure)) is enough for
__builtin_object_size to consider a function free of side effects.

[Bug c/6906] warn about asserts with side effects

2017-07-17 Thread owner at bugs dot debian.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=6906

--- Comment #8 from owner at bugs dot debian.org ---
Thank you for the additional information you have supplied regarding
this Bug report.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 Debian GCC Maintainers 

If you wish to submit further information on this problem, please
send it to 123...@bugs.debian.org.

Please do not send mail to ow...@bugs.debian.org unless you wish
to report a problem with the Bug-tracking system.

[Bug c/6906] warn about asserts with side effects

2017-07-17 Thread felix.von.s at posteo dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=6906

felix  changed:

   What|Removed |Added

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

--- Comment #7 from felix  ---
What's wrong with the __builtin_pure_p approach? Sure, the diagnostics
generated by __attribute__((warning)) will be ugly, but it's still something.
It's also very simple to implement: it's just !TREE_SIDE_EFFECTS().

In fact, I patched my copy of GCC to add __builtin_pure_p defined just like
that and it seems to work fine. Might submit it soon (I didn't write any tests,
though).

[Bug c/6906] warn about asserts with side effects

2016-02-26 Thread owner at bugs dot debian.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=6906

--- Comment #6 from owner at bugs dot debian.org ---
Thank you for the additional information you have supplied regarding
this Bug report.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 Debian GCC Maintainers 

If you wish to submit further information on this problem, please
send it to 123...@bugs.debian.org.

Please do not send mail to ow...@bugs.debian.org unless you wish
to report a problem with the Bug-tracking system.

[Bug c/6906] warn about asserts with side effects

2008-03-02 Thread chris dot pickett at mail dot mcgill dot ca


--- Comment #5 from chris dot pickett at mail dot mcgill dot ca  2008-03-03 
02:55 ---
Maybe you could fix the preprocessor to warn about operators with known side
effects.  Can cpp see the entire expr in assert (expr)?  If so, just search the
tokens for =, ++, --, +=, -=, etc.


-- 

chris dot pickett at mail dot mcgill dot ca changed:

   What|Removed |Added

 CC||chris dot pickett at mail
   ||dot mcgill dot ca


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



[Bug c/6906] warn about asserts with side effects

2006-10-15 Thread pinskia at gcc dot gnu dot org


--- Comment #4 from pinskia at gcc dot gnu dot org  2006-10-15 19:45 ---
*** Bug 29480 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

   What|Removed |Added

 CC||robert at linuxfromscratch
   ||dot org


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