[Bug tree-optimization/81776] missing sprintf optimization due to pointer escape analysis

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Aug 14 15:31:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81776

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
I think GCC needs to avoid performing sprintf optimizations when it sees a
non-standard (i.e., undefined) format conversion (the sprintf pass does).

For Glibc customizations that override standard conversions like %s, the user
needs to explicitly disable the built-in sprintf handling, otherwise the
sprintf -> strcpy or printf -> puts optimizations will defeat them.  Carlos
O'Donell says the Glibc manual should also be updated to make this clear.  To
make it easy to disable all of them (and not forget, say vsnprintf), Carlos
suggests adding a convenience option as an alias for all of
-fno-builtin-{,v}{,f,s,sn}printf and -fno-builtin-{,f}printf-unlocked (at least
I think that's all of them, unless the checking forms also need to be
disabled).


More information about the Gcc-bugs mailing list