This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c/6906: warn about asserts with side effects
- From: bangerth at dealii dot org
- To: 123468 at bugs dot debian dot org, asd at suespammers dot org, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org
- Date: 8 Jan 2003 01:40:59 -0000
- Subject: Re: c/6906: warn about asserts with side effects
- Reply-to: bangerth at dealii dot org, 123468 at bugs dot debian dot org, asd at suespammers dot org, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org
Synopsis: warn about asserts with side effects
State-Changed-From-To: open->feedback
State-Changed-By: bangerth
State-Changed-When: Tue Jan 7 17:40:58 2003
State-Changed-Why:
As much as I sympathize with the goal of such a warning, I
doubt it will be possible to implement it. The reason is
that assert() is usually implemented via a macro. On my
system, it reads (if !NDEBUG):
--------------------
# define assert(expr) \
(__ASSERT_VOID_CAST ((expr) ? 0 : \
(__assert_fail (__STRING(expr), __FILE__, __LINE__, \
__ASSERT_FUNCTION), 0)))
---------------------------
so at the time the _compiler_ (as opposed to the
preprocessor) sees the condition, the special name "assert"
is already gone. On the other hand, the preprocessor doesn't
know anything about expressions with or without side effects.
I thus seriously doubt that such a warning can be implemented
without gross hacks...
W.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6906