if bug in Ritchie C compiler - (nf)

crl crl
Wed Jan 26 12:01:44 AEST 1983


#N:pur-phy:15700005:000:726
pur-phy!crl    Jan 26 11:02:00 1983

I have just noticed a bug in the Ritchie C compiler (or at least
an example of it being too smart for its own good).  Consider the
following:
	main()
	{
		if (foo()*0);
	}
	
	foo()
	{
		printf("in foo\n");
	}

The compiler thinks:  "Well, foo() * 0 is always false, so I won't
even compile the if statement."

I don't think that this should be the way it compiles, what do you
people think?  (I know no sane person would do this, but I had to
fix some software I got from somewhere else where in a complicated
series of #ifdefs someone had decided that this was the easiest
way to have the if always fail.  YECCH!)

The "bug" does not seem to exist in our version of pcc.

Charles LaBrec
pur-ee!Physics:crl
purdue!Physics:crl




More information about the Comp.lang.c mailing list