NSParameterAssert leads to compiler error when using -Weverything -Werror

Originator:neocool2
Number:rdar://19796924 Date Originated:11-Feb-2015 05:45 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Version 6.3 (6D520o)
Classification:Serious Bug Reproducible:Always
 
Summary:

NSParameterAssert leads to a compiler error when using -Weverything -Werror - requiring to either disable the -Wcstring-format-directive entirely or wrap any calls to NSParameterAssert into clang diagnostic pragmas.

Steps to Reproduce:

Compile the attached code:

clang -Werror -Weverything Assert.m 

Expected Results:

It compiles.

Actual Results:

Compiler error:

Assert.m:9:2: error: using %s directive in NSString which is being passed as a
      formatting argument to the formatting method
      [-Werror,-Wcstring-format-directive]
        NSParameterAssert(bar);
        ^
/Applications/Xcode-Beta 2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSException.h:139:38: note: 
      expanded from macro 'NSParameterAssert'
#define NSParameterAssert(condition) NSAssert((condition), @"Invalid par...
                                     ^
/Applications/Xcode-Beta 2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSException.h:102:39: note: 
      expanded from macro 'NSAssert'
                lineNumber:__LINE__ description:(desc), ##__VA_ARGS__]; \
                                                ^
/Applications/Xcode-Beta 2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSException.h:281:1: note: 
      method 'handleFailureInMethod:object:file:lineNumber:description:'
      declared here
- (void)handleFailureInMethod:(SEL)selector object:(id)object file:(NSSt...
^
1 error generated.

Regression:

This used to work fine with previous versions of Xcode, including 6.2

Notes: -

Comments

Workaround

The attached Assert.m file

#import 

@interface Foo : NSObject
@end

@implementation Foo

-(void)foo:(NSString*)bar {
	NSParameterAssert(bar);
}

@end

int main() {
	Foo* f = [Foo new];
	[f foo:@"foo"];
}

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!