This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/6906] warn about asserts with side effects
- From: "mbp at sourcefrog dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Aug 2004 23:56:33 -0000
- Subject: [Bug c/6906] warn about asserts with side effects
- References: <20020601163600.6906.123468@bugs.debian.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From mbp at sourcefrog dot net 2004-08-10 23:56 -------
It might be nice if there were a compile-time function similar to
__builtin_constant_p which checked whether an expression was free of
side-effects. One could then write
# define assert(expr) \
(__builtin_pure_p((expr)) ? _real_assert(expr) :
warning_assert_expr_not_pure())
So this would be true for things like
__builtin_pure_p(arry[0] == 0)
__builtin_pure_p(strlen(s) == 5)
assuming the functions had the right attributes.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=6906