From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1582 invoked by alias); 8 Jan 2003 01:40:59 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 1561 invoked by uid 61); 8 Jan 2003 01:40:59 -0000 Date: Wed, 08 Jan 2003 01:40:00 -0000 Message-ID: <20030108014059.1560.qmail@sources.redhat.com> To: 123468@bugs.debian.org, asd@suespammers.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org From: bangerth@dealii.org 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 Subject: Re: c/6906: warn about asserts with side effects X-SW-Source: 2003-01/txt/msg00502.txt.bz2 List-Id: 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