Subject: cygwin gcc and arrays -- Possible bug???
From: Cynthia Randles <[email-masked]>
To: [email-masked]
Date: Tue, 27 Aug 2002 19:09:23 -0400

I was wondering if anyone could help me.  
I have the following lines of code:

      	for (i = 0; i <=  NUMBINS; ++i)
	{
	      printf("--------read in input files---------\n");
	      printf("The value if i is %d\n", i);
	      fscanf(ifp1, "%f\n", &radius_microns);
	      fscanf(ifp2, "%f\n", &volfraction);
	      printf("The value of radius is %f\n", radius_microns);
	      rad_array[i]= radius_microns;
	     
	      printf("The radius is rad_array[%d]=%f\n\n",i, rad_array[i]);
	       
 	      printf("The value of volfraction is %f\n", volfraction);
	      vol_array[i] = volfraction;
	      printf("The volfraction is vol_array[%d]=%f\n", i, vol_array[i]);
	      printf("The value of rad_array[%i] is %f\n", i, rad_array[i]);
	      printf("----------end of read in input file------\n\n");
	}

which, in cygwin produces:
 
--------read in input files---------
The value of i is 0
The value of radius is 0.200000
The radius is rad_array[0] = 0.200000

The value of volfraction is 0.330000
The volfraction is vol_array[0]=0.330000
The value of rad_array[0] is 0.330000
----------end of read in input file-----

as you can see, for some reason rad_array[0] is being reassigned even
though I never ask for that!!!

my red-hat linux gcc produces:

--------read in input files---------
The value of i is 0
The value of radius is 0.200000
The radius is rad_array[0] = 0.200000

The value of volfraction is 0.330000
The volfraction is vol_array[0]=0.330000
The value of rad_array[0] is 0.200000
----------end of read in input file-----

which is the right answer.  I cannot figure out what is going
on with cygwin, and I haven't found a post that can help me.  Any
help is appreciated.

Thanks,
Cynthia

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/