Path: utzoo!attcan!uunet!virtech!cpcahil From: cpcahil@virtech.uucp (Conor P. Cahill) Newsgroups: comp.lang.c Subject: Re: compare strings, strcmp Keywords: strcmp,strings Message-ID: <1989Nov21.003145.27917@virtech.uucp> Date: 21 Nov 89 00:31:45 GMT References: <4463@blake.acs.washington.edu> <11605@smoke.BRL.MIL> <308@charyb.COM> <5139@mnetor.UUCP> Organization: Virtual Technologies Inc. Lines: 21 In article <5139@mnetor.UUCP>, lazer@mnetor.UUCP (Lazer Danzinger) writes: > +This macro is "unsafe" because the macro arguments a and b are used twice, > +hence possible side effect difficulties... > I see no possibility of side effects. What is unsafe is the > referencing of the location where a and b point to, without > first checking that they are not null pointers. wrongo. you (the programmer) must do that before calling StrEqu. This macro was designed to be a replacement for using strcmp directly and therefore has the same requirements as the strcmp function itself. Calling strcmp with a null pointer will result in a core dump on lots of machines and undefined behavior on all others. The side effects have been addressed in lots of other posts in this thread. -- +-----------------------------------------------------------------------+ | Conor P. Cahill uunet!virtech!cpcahil 703-430-9247 ! | Virtual Technologies Inc., P. O. Box 876, Sterling, VA 22170 | +-----------------------------------------------------------------------+