Bug#123468: c/6906: warn about asserts with side effects
- To: 123468@bugs.debian.org, asd@suespammers.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org
- Subject: Bug#123468: c/6906: warn about asserts with side effects
- From: bangerth@dealii.org
- Date: 8 Jan 2003 01:40:59 -0000
- Message-id: <[🔎] 20030108014059.1560.qmail@sources.redhat.com>
- Reply-to: bangerth@dealii.org, 123468@bugs.debian.org, asd@suespammers.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org, 123468@bugs.debian.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
Reply to: