Hello.

gcc always replaces the name of the defined "__builtin_abs()" with "abs()". And
it might cause the error if we also wants to define "abs()" function:

$ cat t.c
int abs(int a) {return 0;}
int __builtin_abs(int a) {return 0;}
int main(void)
{
    return (abs(-3) + __builtin_abs(-3));
}

$ gcc t.c -c
/tmp/ccdecizd.s: Assembler messages:
/tmp/ccdecizd.s:14: Error: symbol `abs' is already defined



In the case of "static" functions it's OK:

$ cat t.c
static int abs(int a) {return 0;}
static int __builtin_abs(int a) {return 0;}
int main(void)
{
    return (abs(-3) + __builtin_abs(-3));
}

$ gcc t.c -c ; echo $?
0

In this case we use unchanged names for the functions' call:

$ gcc t.c -S && grep call t.s
        call    abs
        call    __builtin_abs


This issue doesn't occur only on abs but also with the others builtins.

$ ~/programs/gcc-4.4.0/bin/gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ./configure --prefix=/home/glushkov/programs/gcc-4.4.0
--enable-languages=c,c++
Thread model: posix
gcc version 4.4.0 (GCC)

$ uname -a
Linux expert 2.6.23-gentoo-r9-c2-uni1 #1 SMP Thu Jun 5 13:00:21 MSD 2008 i686
Intel(R) Pentium(R) 4 CPU 3.40GHz GenuineIntel GNU/Linux


-- 
           Summary: definitions of __builtin_abs() and abs() function in one
                    module
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ivan dot glushkov at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40485

Reply via email to