
On Sat, Jan 28, 2012 at 11:34 PM, Olaf van der Spek <ml@vdspek.org> wrote:
On Fri, Jan 27, 2012 at 5:32 PM, Domagoj Saric <domagoj.saric@littleendian.com> wrote:
a) the lifetime management bool was changed into a properly typed pointer (this actually takes the same amount of space while it provides a no-op
AFAIK bool and pointer aren't the same size. How can it still take the same amount of space?
Olaf
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
My guess would be that the compiler promotes the size of a bool to that of the native word size of the machine because the ease and speed of aligned memory access outweigh the 'size savings' (as typically your object is going to need to occupy an entire register, word on the stack, etc -- except when in an array, but that's actually another reason you want to have the size of the object promoted, as again, unaligned memory access is slow). Afaik though, in code it will typically still be treated as if it were e.g. 1 byte on x86 (using the AL register instead of EAX), and simply ignoring the high portion of the register. Note: Not a compiler/optimization/cpu/etc expert. This is just my amateur 'guess'. If you are really curious, just compile a test and disassemble it with GDB/WinDbg/IDA/etc, testing the codegen for various scenarios and optimization flags.