🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1660

Re: ANSI assert

#1660
From: John R. Levine
Date: Sun, 09 Sep 1990 02:52
18 lines
1374 bytes
In article <1428@proto.COM> you write:
>  assert(i++ < limit);

Asserts with side effects have always been a bad idea, as is practically
any macro call with side effects.  Every implementation of assert that I
have ever seen throws away the argument to assert without evaluating it if
NDEBUG is defined.  You have my condolences if this breaks your programs,
but even before ANSI such programs had major portability problems.  If you
ever plan to use a compiler other than the one you're using now, you'd
better plan to fix your code.

This is a famous problem by now, I know lots of programs that couldn't be
shipped with NDEBUG set exactly because there were side effects in the
asserts.  (I think this is an argument for better programmer education
rather than fudging the language to the tastes of sloppy programmers.)

Regards,
John Levine, johnl@esegue.segue.boston.ma.us, {spdcc|ima|world}!esegue!johnl
Technical Details
Message-ID: <9009082252.AA16290@esegue.segue.boston.ma.us>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!watserv1!watmath!att!occrsh!uokmax!apple!usc!snorkelwacker!mintaka!spdcc!esegue!Postmaster

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!watserv1!watmath!att!occrsh!uokmax!apple!usc!snorkelwacker!mintaka!spdcc!esegue!Postmaster
From: johnl@esegue.segue.boston.ma.us (John R. Levine)
Newsgroups: comp.std.c
Subject: Re: ANSI assert
Message-ID: <9009082252.AA16290@esegue.segue.boston.ma.us>
Date: 9 Sep 90 02:52:49 GMT
Sender: Postmaster@esegue.segue.boston.ma.us
Organization: Segue Software, Cambridge MA
Lines: 18
In-Reply-To: <1428@proto.COM>