News for hackers. Stuff that matters.
Re:Where the Printf Rubber Meets the Road (2010) by DannyBee on Saturday October 04, 2014 @09:11PM (#8411122)
You did miss one fun rabbit hole with printf in glibc:

Search for register_printf_function, and realize that printf is now a function that can have whatever side-effects you like (which really sucks for optimization around logging code)

Re:Where the Printf Rubber Meets the Road (2010) by jzwinck on Saturday October 04, 2014 @09:29PM (#8411158)
Glibc may have register_printf_function, but GCC does not have register_printf_attribute, so this is not as practical as it could be. That is:

    __attribute__ ((format (printf, 1, 2)))
attaches to a function declaration to indicate that the function works like printf, so GCC can warn if a (compile time) format string does not match the variadic arguments. But there seems to be no way to extend this attribute, nor to make entirely new attributes in the same spirit.

So you can register new format specifiers for printf, but it seems you'll then have to disable warnings about bad format specifiers during compilation. Those warnings have very few false positives and catch real bugs in real code.

Re:Where the Printf Rubber Meets the Road (2010) by DannyBee on Saturday October 04, 2014 @10:57PM (#8411321)
"But there seems to be no way to extend this attribute, nor to make entirely new attributes in the same spirit."

Yes, GCC knows, and we're good with that :)

The glibc extension here serves no earthly purpose (and on the gcc side, we've considered pretending it doesn't exist before so we can actually optimize better).

It sounds like it may be a good idea, except 1. It modifies functions that have a standard purpose, standard set of format specifiers, and are, as you point out, often error checked to make sure they match those :)

2. Unless you see the printf handler registration, which may be in a library, linked to your program, or whatever, you'll have no idea that the code is wrong.

Re:Where the Printf Rubber Meets the Road (2010) by cremno on Saturday October 04, 2014 @10:10PM (#8411241)
The Plan 9 C compilers have #pragma varargck (argpos|type|flag):

http://plan9.bell-labs.com/sys/doc/compiler.html (3.8)