I recently discovered an error in my code that took several hours to debug.
the problem was a function defined as:
unsigned int foo(unsigned int i){
long int v[]={i-1,i,i+1} ;
.
.
.
return x ;
}
The definition of v did not cause any problems on my development machine (ubuntu compiler 12.04 32 bit, g ++), where unsigned ints were implicitly converted to long ints and as such negative values were correctly processed.
On another machine (ubuntu 12.04 64 bit, g ++ compiler), however this operation was not safe. When I = 0, v [0] was not set to -1, but to some strange big value (as is often the case when trying to make unsigned int negative).
I could solve the problem by setting the value i to long int
long int v[]={(long int) i - 1, (long int) i, (long int) i + 1};
( ).
, .
, ?