Re: How to debug a corrupted stack
Re: How to debug a corrupted stack
- Subject: Re: How to debug a corrupted stack
- From: Johannes Fortmann <email@hidden>
- Date: Thu, 7 Aug 2008 18:55:40 +0200
The problem here is that UTCDateTime is defined with #pragma pack 2 in
effect. That means the compiler packs with an alignment of 2, so the
whole structure has 8 bytes. The proper alignment (4) results in 12
bytes. Since there's nothing in the @encode'd information specifying
the non-standard alignment, NSGetSizeAndAlignment (which NSValue
probably uses internally) will return 12 bytes as the struct's size.
As an example,
#include <Foundation/Foundation.h>
void main()
{
NSUInteger size, align;
NSGetSizeAndAlignment (@encode(UTCDateTime),
&size,
&align);
printf("%i, %i, %s\n", sizeof(UTCDateTime), size,
@encode(UTCDateTime));
}
prints "8, 12, {UTCDateTime=SIS}".
HTH,
Johannes Fortmann
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden