Re: subtle bug possibility




Nathan Froyd <maestrox@geocities.com> writes:

> This code doesn't want to run on gtk 0.99.3:
> 
>   for(i=0;i<4;i++){
>     column[i] = gtk_hbox_new(TRUE, 3);
>     for(j=0;j<4;j++){
>       drawbox[(i+1)*(j+1)+(3-j)*i] = gtk_drawing_area_new();

This, and similar statements look like the problem to me.

Expanding the bracketed expression, we get 

   i*j + i + j + 1 + 3*i - i*j = 4*i + j + 1

But the indices should be 0..15. So you probably wanted simply:

   drawbox[4*i + j] = ....

Hope this helps,
                                        Owen



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