[cfe-dev] Even more clang ideas

Chris Lattner clattner at apple.com
Fri Jul 25 22:09:36 PDT 2008

On Jul 25, 2008, at 6:28 PM, Ted Kremenek wrote:

>> It really starts to become a problem when you turn on the optimizer
>> and it begins to do optimizations that are dependent on this
>> aliasing invariant.  When I realized that this could actually be a
>> serious, very subtle problem, and started digging I found evidence
>> to support it.  For example, '-fstrict-aliasing' is disabled on
>> Apples GCC for ObjC code.
> Interesting.  I think this illustrates my point that the strict
> aliasing rules in C99 don't really apply to Objective-C, at least in
> the implementation provided by GCC.  This is clearly a deliberate
> choice, likely to avoid the issues you mentioned.

-fstrict-aliasing being off by default has more to do with its  
implementation in GCC than it does the objc type system.  I don't  
think that any of the things John is talking about affect -fstrict- 

When llvm-gcc (and eventually clang) supports type based alias  
analysis, it will almost certainly be on by default, even on the mac.

>> Using '-fast' on .m files causes the compiler to emit 'cc1obj:
>> warning: command line option "-fast" is valid for C/C++ but not for
>> ObjC'

-fast is basically the "optimize for SPEC" flag.  There are no objc  
programs in spec.


More information about the cfe-dev mailing list