[Bug c/72750] New: Not possible to use -fno-builtin to suppress optimization of some standard functions like atoi

2016-07-29 Thread david.l.kreitzer at intel dot com
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-.

That doesn't work for functions like atoi that have inline implementations in
the headers. For example:

 t.c 
#include 
#include 
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?

[Bug c/72750] Not possible to use -fno-builtin to suppress optimization of some standard functions like atoi

2016-07-30 Thread david.l.kreitzer at intel dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72750

--- Comment #3 from David Kreitzer  ---
Thanks for the prompt responses.

Please consider the fact that the same behavior also occurs with "gcc -S -O2
-ffreestanding t.c".

Wouldn't you agree that using the inline implementation of atoi from the
headers is a clear violation of freestanding semantics?