[LLVMbugs] [Bug 10274] New: format function attribute with the NSString archetype yields no compiler warnings

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jul 4 23:10:50 PDT 2011


http://llvm.org/bugs/show_bug.cgi?id=10274

           Summary: format function attribute with the NSString archetype
                    yields no compiler warnings
           Product: clang
           Version: 2.9
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: macbavarious at gmail.com
                CC: llvmbugs at cs.uiuc.edu


The following code:

#import <Foundation/NSString.h>

extern void test0(const char *format, ...) __attribute__((format(__printf__, 1,
2)));
extern void test1(NSString *format, ...) __attribute__((format(__NSString__, 1,
2)));

void function(void) {
    test0("%d");
    test0("%d", "foo");

    test1(@"%d");
    test1(@"%d", "foo");
}

yields warnings for test0() calls only:

$ clang -c -Wformat bug0.m
bug0.m:7:13: warning: more '%' conversions than data arguments [-Wformat]
    test0("%d");
           ~^
bug0.m:8:13: warning: conversion specifies type 'int' but the argument has type
'char *' [-Wformat]
    test0("%d", "foo");
           ~^   ~~~~~
           %s
2 warnings generated.

so it seems that the __NSString__ archetype doesn't yield compiler warnings
when there's a mismatch between the format NSString and the arguments.

This has been tested with:

$ clang --version
Apple clang version 2.0 (tags/Apple/clang-137) (based on LLVM 2.9svn)
Target: x86_64-apple-darwin10
Thread model: posix

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list