Comment 4 for bug 547016

Revision history for this message
Kees Cook (kees) wrote :

Please be extremely careful with -U_FORTIFY_SOURCE as disabling this takes away a large number of important protections.

gcc does warn about the behavior when it can detect it at compile time (it cannot with varargs). If you change testfunc to printf:
$ cc -O2 test.c -o test
test.c: In function ‘main’:
test.c:17: warning: format argument 1 unused before used argument 5 in $-style format
test.c:17: warning: format argument 2 unused before used argument 5 in $-style format
test.c:17: warning: format argument 3 unused before used argument 5 in $-style format
test.c:17: warning: format argument 4 unused before used argument 5 in $-style format