This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/81772] New: Compile-time snprintf optimization
- From: "bugzilla at poradnik-webmastera dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 08 Aug 2017 16:01:01 +0000
- Subject: [Bug c/81772] New: Compile-time snprintf optimization
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81772
Bug ID: 81772
Summary: Compile-time snprintf optimization
Product: gcc
Version: 5.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: bugzilla@poradnik-webmastera.com
Target Milestone: ---
snprintf is slow. This is caused not only by format string handling, but there
is also some internal fault with string handling - see
https://sourceware.org/bugzilla/show_bug.cgi?id=21905 . Because of this it
would be nice if gcc could perform some compile-time optimization. The best
would be to parse format string at compile time and generate appropriate code
for it, so there would be no format parsing at runtime at all. However any
partial optimization here would be helpful. I found that sprintf with %s format
is replaced with strcpy. snprintf with %s format could be replaced with strlcpy
- unfortunately is is not supported yet by gcc/glibc, so other approach is
needed (or implement strlcpy/strlcat and use them :))