[comp.lang.c] Old-fashioned Initialization

jdc@naucse.UUCP (John Campbell) (02/09/88)

Do all bugs bite?  This short program ran under unix on a 3b1 (and Ultrix).
On VMS but it failed because I forgot =- is an "old-fashioned" initialization 
(I was in a hurry :-).  In hindsight, my 3b1, did the same, but "x" was 0.  
On VMS x is 0 in the debugger--otherwise it's garbage.  Neither VMS or the 
3b1 said a thing about this section of code! My third try, on Ultrix, warned:
   line 6: warning: ambiguous assignment: assignment op taken
   line 6: warning: old fashioned assignment operator
Lint (which I don't have on VMS) added:
   line 6: warning: x be used before set.

So, two out of three compilers agree--give the user a quiet history lesson!
(Is =- in dpAns 'C'?)  (Are warning messages so awful?)

#include <math.h>
#define PI 3.14159265
main ()
{
   float x;
   for (x=-3*PI; x < 3*PI; x += PI/8.0)  /* Change to x = -3*PI */
      printf ("%f %f\n", x, sin(x)/x);
}
-- 
	John Campbell               ...!arizona!naucse!jdc

	unix?  Sure send me a dozen, all different colors.

ftw@datacube.UUCP (02/12/88)

jdc@naucse.UUCP writes:

> So, two out of three compilers agree--give the user a quiet history lesson!
> (Is =- in dpAns 'C'?)  (Are warning messages so awful?)

[code deleted]

I don't beleive that =op is in dpANS.  Some compilers *wouldn't* issue a
warning, and quietly give you =op instead of = (unary)op.  Whitesmith's
used to do this.

>	John Campbell               ...!arizona!naucse!jdc

				Farrell T. Woods 

Datacube Inc. Systems / Software Group	4 Dearborn Rd. Peabody, Ma 01960
VOICE:	617-535-6644;	FAX: (617) 535-5643;  TWX: (710) 347-0125
INTERNET: ftw@datacube.COM
UUCP: {rutgers, ihnp4, mirror}!datacube!ftw

"OS/2 -- Half an operating system"

henry@utzoo.uucp (Henry Spencer) (02/22/88)

> I don't beleive that =op is in dpANS...

Correct; it isn't.  The Rationale does note this as a "quiet change", i.e.
one that can silently break existing code, but observes that even K&R said
that =op was obsolete.  I expect that most sensible compilers will continue
to complain about anything that looks like =op for quite a while yet.
-- 
Those who do not understand Unix are |  Henry Spencer @ U of Toronto Zoology
condemned to reinvent it, poorly.    | {allegra,ihnp4,decvax,utai}!utzoo!henry