On Sat, Aug 26, 2006 at 12:47:16PM -0500, Jacob Yocom-Piatt wrote:
> while debugging some C code, i encountered an odd issue that i haven't seen
> before. the trouble is with spacing and nested array evaluation. the line(s)
> of
> code in question look like
>
> u_int8_t y0, y1, y2, y3;
>
> ...
>
> y0 = Q1[ Q0 [ Q0[y0] ^ b0(L[1]) ] ^ b0(L[0]) ];
> ^^
> where there is either 1 or 2 spaces after the first open square bracket and
> the
> Q's are fixed permutations [1] that map u_int8_t --> u_int8_t. if the above
> code
> is broken out like so
>
> y0 = Q0[y0] ^ b0(L[1]);
> y0 = Q0[y0] ^ b0(L[0]);
> y0 = Q1[y0];
>
> it outputs the 2-space result.
>
> i have verified that the input y0 is the same in both the 1-space and 2-space
> cases, but the results differ between the two cases. the 1-space output is
>
> a5 1f 5b 0
>
> and the 2-space output is
>
> b3 1f 5b a5.
>
> i suspect this is some C nuance of which i'm unaware. the 2-space output is
> the
> one that i expect is "correct". cluestick me please.
There is no difference between the versions; something else is
different. For truly weird problems, running with a lot of memory
protection (see malloc(3), MALLOC_OPTIONS) may be useful...
Joachim