This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/81776] missing sprintf optimization due to pointer escape analysis
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 14 Aug 2017 15:30:08 +0000
- Subject: [Bug tree-optimization/81776] missing sprintf optimization due to pointer escape analysis
- Auto-submitted: auto-generated
- References: <bug-81776-4@http.gcc.gnu.org/bugzilla/>
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).