No format security warnings in Xcode 4.4

2020-07-27 11:53发布

问题:

I don't get any format security warnings (-Wformat-security) from this code using Xcode 4.4:

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{

    @autoreleasepool {

        // a = @"%@" or a = @"%@%@"
        NSString *a = [@"%@" stringByAppendingFormat:@"%@", arc4random_uniform(2)? @"%@": @"", nil];

        // 50% change of crash, but no warning
        NSLog(a, @"Hello, World!");

    }
    return 0;
}

Is this normal or have I somehow disabled this warning in Xcode?

I have just created the project with this code, so it haven't changed the project settings from the default.