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?

Reply via email to