On 10/23/08 12:06 AM, Ken Ferry said:

>The function is actually implemented a bit better than the cast above, in
>that the function does not violate strict aliasing[1].

And gcc will warn you if you ask it:

-----------
#import <Cocoa/Cocoa.h>

int main(void)
{
        CGPoint myCGPoint = {0.0, 0.0};
        NSPoint point = *(NSPoint *)&myCGPoint;
        NSPoint point2 = NSPointFromCGPoint(myCGPoint);

        return 0;
}
-----------

/usr/bin/gcc-4.2 -Wstrict-aliasing -fstrict-aliasing /Users/sean/Desktop/
test.m

/Users/sean/Desktop/test.m:6: warning: dereferencing type-punned pointer
will break strict-aliasing rules

Alas, it's not feasible to have this option on in a real-world Cocoa
program, since gcc will also warn just about anywhere you use 'super',
ex: 'self = [super init]'. :(  <rdar://5509903>

--
____________________________________________________________
Sean McBride, B. Eng                 [EMAIL PROTECTED]
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to