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 Message-ID: <4460@segue.segue.com> Date: 4 Nov 90 20:17:46 GMT References: <18647@rpp386.cactus.org> <4057@awdprime.UUCP> <18658@rpp386.cactus.org> <4430@segue.segue.com> <18664@rpp386.cactus.org> <4447@segue.segue.com> <18689@rpp386.cactus.org> Reply-To: jim@segue.segue.com (Jim Balter) Organization: Segue Software, Inc. - Santa Monica, CA. +1-213-453-2161 Lines: 31 In article <18689@rpp386.cactus.org> jfh@rpp386.cactus.org (John F. Haugh II) writes: >as i said, it was a fake example. you pay your money, you take your chances. I hope no one is paying you money for your advice. >i typically don't use assert, for exactly the reasons i've mentioned. if i >want a core dump, i write "abort()". if i want an error message, i use >perror or fprintf. And if you want to make an assertion about a logical state, you ... oh, a new concept for you, eh? >but i have found assert to vary from machine to machine >enough to be useless. In other words, all your talk about how to use assert portably is hot air. Why did you bother? The fact of the matter is that there is plenty of portable code that uses assert, without an explicit call to exit. What assert does after it prints a message is irrelevant to portability because proper usage of assert (as opposed to your examples) in working code never prints a message. An assertion failure should only occur during debugging, and indicates a logic error in the program. The fact that some implementations may return from assert if SIGABORT is ignored is irrelevant because (a) no real program ignores SIGABORT (b) the printing of an assert message is an indication that the program has malfunctioned and needs debugging, and the behavior of the program *after* the assert message is printed is of little concern. And whether abort dumps core or not is an issue outside the ANSI C standard and is hardly a portability issue. Once you get an assert failure; it is time to debug; you can force all the core dumps you want.