On Wed, Aug 3, 2011 at 11:18 AM, Stefan Dösinger stefandoesinger@gmx.at wrote:
On Wednesday 03 August 2011 10:56:25 Michael Mc Donnell wrote:
It is *technically* undefined, but all the compilers I have tested it on do the same thing.
There may be a future compiler that behaves differently. You may get away with it right now, but it will cause pain in the rear sooner or later.
(I didn't know bitfield layout is undefined, otherwise I wouldn't have advised you to keep using them)
Looking at the ISO C99 draft I can't find anything about the memory layout being undefined. Only that things are implementation specific like alignment, padding, and endianness. Not much unlike the definition of int :-)
Anyway you're right it's probably a good idea to stay clear of them in order to avoid potential compiler issues. I've updated the patch to implement UDEC3 and UDEC3N using shifts and masks instead of bit-fields. It will still only work on little-endian machines though. Does it look ok?
Thanks, Michael