Re: std min error during optimization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



TRaj <tryitn1@xxxxxxxxx> writes:

> int g(int mask,int lvl){
>   assert(mask<(1<<N));
>
>    printf("MASK=%d\n",mask);
>
> 	if(gdo2[mask]) return gdo2[mask];
>
> 	if(lvl==N){
> 		if(done[mask]) return INF;
> 		 return mask;
> 	 }
>  	 int ans=INF,i;
> 	 if(done[mask]==0) ans=mask;
> 	for(i=0;i<N;i++)
> 		if((mask&(1<<i))){
> 			ans=min(ans,min(g(mask^(1<<i) ,lvl+1),g(mask,lvl+1)));
> 		}
>
> 	return gdo2[mask]=ans;
>
> }

In this line:

> 			ans=min(ans,min(g(mask^(1<<i) ,lvl+1),g(mask,lvl+1)));

the function g calls itself twice.  The order of those function calls is
undetermined and will be different depending upon the function is
compiled.  This is a problem since g acts differently based on global
variable state.

Ian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux