problem with builtin functions

Herman ten Brugge Haj.Ten.BruggeATnet.HCC.nl
Tue Sep 14 22:57:00 GMT 1999


Hello,

I have a problem with builtin functions for the c++ compiler. When I compile
the next program:

typedef unsigned int size_t;

static inline int memcmp(const void *mem1, const void *mem2, size_t length)
{
   const char *r1 = (const char *)mem1 - 1;
   const char *r2 = (const char *)mem2 - 1;

   for(;;)
     if      ( --length == (size_t)-1 ) break;
     else if ( *++r1 != *++r2 ) return *r1 - *r2;

   return 0;
}

I get an assembly file (i386):

        .file   "q.c"
        .version        "01.01"
gcc2_compiled.:
.text
        .align 16
.globl memcmp
        .type    memcmp,@function
memcmp:
.LFB1:
        pushl   %ebp
...

The problem is that it defines the function memcmp as global. This function
was in a header file and got compiled multiple times. The linker complained
that the memcmp was present in more then one module. When I used -fno-builtin
the problem went away. This problem is present in the egcs-19990913 release
and not in the gcc-2.95.1 release.

	Herman.


More information about the Gcc-bugs mailing list