This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/72750] New: Not possible to use -fno-builtin to suppress optimization of some standard functions like atoi
- From: "david.l.kreitzer at intel dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 29 Jul 2016 20:04:48 +0000
- Subject: [Bug c/72750] New: Not possible to use -fno-builtin to suppress optimization of some standard functions like atoi
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72750
Bug ID: 72750
Summary: Not possible to use -fno-builtin to suppress
optimization of some standard functions like atoi
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: david.l.kreitzer at intel dot com
Target Milestone: ---
For some standard functions like memset, the programmer can override the
standard function with a custom implementation using -fno-builtin or
-fno-builtin-<name>.
That doesn't work for functions like atoi that have inline implementations in
the headers. For example:
---- t.c ----
#include <stdlib.h>
#include <string.h>
int f1(void *p, const char *s)
{
memset(p, 0, 16);
return atoi(s);
}
-------------
With "gcc -S -O2 t.c", both calls get optimized. Adding -fno-builtin-memset
suppresses the memset optimization, enabling the programmer to provide their
own implementation of memset. Adding -fno-builtin-atoi has no effect.
Would this be considered a bug or a feature? And if the latter, is there a
recommended method for suppressing the optimization of atoi without completely
disabling inlining or optimization in general?