[Gc] libatomic_ops-7.2alpha4 alignment issue on x64 using Microsoft VC9 on WindowsXP64

Pete Johnson pete at imedic.org
Thu Mar 25 16:18:32 PST 2010


Hi

I've recently ported an application using the atomic ops calls from 
win32 to x64, and have run into an assertion issue. The code ran 
perfectly on win32.

AO_load() and AO_store() in aligned_atomic_load_store.h both have 
asserts in them which are confirming that the addresses passed are 8byte 
aligned (on x64). However, these asserts are failing in my code when 
passing the address of a stack based variable.

using the Microsoft __alignof() call confirms the address is 8 byte 
aligned, and that the sizeof() returns 8 too. However, the actual 
address is not divisible by 8 - the check in the assert

((size_t)addr & (sizeof(AO_t) - 1))

gives a result of 4.

I'm perplexed by this - Microsoft state that on x64 the stack is 16 byte 
aligned. Although commenting out the asserts produces code that appears 
to function OK, I'd sleep more easily if there was some rational 
explanation of this. Can anyone help?

Many thanks.

Pete
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://napali.hpl.hp.com/pipermail/gc/attachments/20100326/e23b9a1b/attachment.htm


More information about the Gc mailing list