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

mbp at sourcefrog dot net gcc-bugzilla@gcc.gnu.org
Tue Aug 10 23:56:00 GMT 2004


------- 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



More information about the Gcc-bugs mailing list