a.out gives different results when compiled by g++ 3.1 and g++ 3.1 -O
Erick Alphonse
alphonse@lri.fr
Sun Jun 16 12:34:00 GMT 2002
Falk Hueffner wrote:
>> enum {N = 624, // length of state vector
>> M = 397, // period parameter
>> MAGIC = 0x9908B0DFU}; // magic constant
>>
>> ui32 state[N]; // internal state
>>[...]
>>*p++ = twist( p[M-N], p[0], p[1] );
>>
>
> You're accessing out of the array bounds here, so anything might
> happen.
>
Dear Falk,
I have found the latest version of the code, and the guy goes:
v0.7 - Fixed operator precedence ambiguity in reload()
which gives:
for( i = N - M; i--; ++p )
*p = twist( p[M], p[0], p[1] );
for( i = M; --i; ++p )
*p = twist( p[M-N], p[0], p[1] );
I suppose it's what your were talking about. So there is no standard and
the behaviour may depend on optmization?
Regards,
Erick.
More information about the Gcc-bugs
mailing list