
5 Nov
2012
5 Nov
'12
9:03 p.m.
Hi!
In message 20121104003242.92729200056@gemini.denx.de I wrote:
/* Append length in bits and transform */
- ctx->in32[14] = ctx->bits[0];
- ctx->in32[15] = ctx->bits[1];
- memcpy(ctx->in + 14 * sizeof(__u32), ctx->bits, 2 * sizeof(__u32));
This makes the code actually unreadable. Please add at least a comment what this is doing.
Actually I think this shoul dbe split into two memcpy commands, using the addresses of the respective array elements directly, without such manual pointer arithmetics.
I guess bigger question is: why does gcc miscompile that, and is it guaranteed that it will not miscompile the memcpy?
Is compiler barrier somewhere better solution? Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html