Old-fashioned Initialization

John Campbell jdc at naucse.UUCP
Tue Feb 9 03:34:10 AEST 1988


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.



More information about the Comp.lang.c mailing list