'Possibly Incorrect Assignment' warnings from Turbo-C

Dave Hammond daveh at marob.masa.com
Sat Nov 25 05:07:29 AEST 1989


In porting a program from Unix to Dos, I get an error from Turbo-C
`Possibly incorrect assignment' with code similar to the following:

char *p, *func();

if (p = func())
	do_something();

Am I fooling myself by ass/u/ming that func() will always be invoked
and its return value assigned to p, before p is evaluated ?  Should
I change all such assignments to include an additional set of parens?

if ((p = func()))
	do_something()

--
Dave Hammond
daveh at marob.masa.com



More information about the Comp.lang.c mailing list