Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!randvax!segue!jim From: jim@segue.segue.com (Jim Balter) Newsgroups: comp.unix.internals Subject: Re: Checking Exit Codes (was: Re: Trojan Horses) Message-ID: <4447@segue.segue.com> Date: 2 Nov 90 02:22:45 GMT References: <18647@rpp386.cactus.org> <4057@awdprime.UUCP> <18658@rpp386.cactus.org> <4430@segue.segue.com> <18664@rpp386.cactus.org> Reply-To: jim@segue.segue.com (Jim Balter) Organization: Segue Software, Inc. - Santa Monica, CA. +1-213-453-2161 Lines: 37 In article <18664@rpp386.cactus.org> jfh@rpp386.cactus.org (John F. Haugh II) writes: >In article <4430@segue.segue.com> jim@segue.segue.com (Jim Balter) writes: >>You could avoid some embarrassment by testing your claims before making them >>public. It would appear that you've never actually used assert, or that when >>you do you don't follow the practice you recommend. > >ah, but i do try these things out - >| signal (SIGIOT, SIG_IGN); >| assert (argc == 2); >| printf ("hi dave!\n"); The claim I was referring to was not that assert can be made to return on some systems, but rather that easy portable programming of asserts involve a call to exit. In the normal use of assert, the code following the assert is executed under normal conditions. The examples you give are simply not real uses of assert. Assert is not intended to be used to print error messages, as you seem to use it in your malloc example. A reasonable use is something like assert(ptr != NULL); /* I (the programmer) believe that the logic of the program precludes the possibility of ptr being NULL at this point. If there is a coding error that does allow ptr to be NULL, this assert will detect it and prevent the next line from referencing location 0, as long as the program is not being compiled with NDEBUG defined */ foo(*ptr); Now, just where do you intend to insert the exit in this fragment of code? >some people ... Indeed.