Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 64 bit addressing



On Saturday, June 28, 2003, at 15:16, Timothy J. Wood wrote:
On Saturday, June 28, 2003, at 12:10 PM, Chris Kane wrote:
[...]
Hopefully when 64-bit tasks become a real possibility for developers, there will be compiler options to complain about pointer-to-int conversions even if there is a cast, or to ignore many kinds of casts, or whatever. Options that could be turned on to help the conversion, then turned off again (probably).
[...]

Fortunately, there already is such a warning:

void *foo(unsigned short x)
{
return (void *)x;
}

foo.c: In function `foo':
foo.c:3: warning: cast to pointer from integer of different size

Presumably this would take effect for the congruent case of a 32-bit int being casted to a 64-bit pointer.

But what will somebody have done when they got that warning? The point is they would have changed the return statement to this to shut up the compiler:

return (void *)(int)x;

In this particular example, in a 64-bit world this may continue to produce no warning and it may be fine. Or it may not be. (This particular example is too trivial to say much about it.) Or it may go back to producing the warning (if int remains the same size). But all such things should probably be looked at at least once by somebody and vetted, if one wants to be robust about the conversion. Squelching all the new warnings will only go so far. That's why something like an "ignore some/all type casts" might be needed (casts for const or other qualifiers aren't interesting). Of course it should be up to developers NOT to ever turn on the option. But wouldn't you feel better if the OS software had at least been looked at this way? (Whether it has been or will be, however, is a separate unanswerable question....)


Chris Kane
CoreFoundation
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: 64 bit addressing (From: "Timothy J. Wood" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.