GCC and Clang report multiple copies of printf bad argument format error

Originator:simon
Number:rdar://10116640 Date Originated:2011-09-13
Status:Closed Resolved:2012-01-27
Product:Developer Tools Product Version:
Classification:Other bug Reproducible:Always
 
Summary:
GCC and Clang as installed with Xcode 4.1 both give duplicate warnings for the -Wformat flag when using printf with the wrong format specifiers.

Steps to Reproduce:

$ cat test.c 
#include <stdio.h>
int main (int argc, char const *argv[])
{
    printf("%i\n", 0l);
    return 0;
}
$ gcc -Wall -o /dev/null test.c 

Expected Results:

test.c: In function ‘main’:
test.c:5: warning: format ‘%i’ expects type ‘int’, but argument 2 has type ‘long int’

Actual Results:

test.c: In function ‘main’:
test.c:5: warning: format ‘%i’ expects type ‘int’, but argument 2 has type ‘long int’
test.c:5: warning: format ‘%i’ expects type ‘int’, but argument 2 has type ‘long int’

Regression:

Notes:

It appears this is because in Apple's stdio.h, the printf() declaration has an unnecessary GCC format attribute attached to it. See the accepted answer to this Stack Overflow question:

http://stackoverflow.com/questions/7380880/why-does-gcc-show-duplicate-warnings-for-bad-printf-format-specifier



27-Jan-2012 10:28 PM Oscar Hernandez :
Engineering has provided the following feedback regarding this issue:

We have no plans to fix this in GCC, only in Clang.

We consider this issue resolved.

Comments


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!