[Bug c/40485] New: definitions of __builtin_abs() and abs() function in one module

2009-06-18 Thread ivan dot glushkov at gmail dot com
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
callabs
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



[Bug c/40485] definitions of __builtin_abs() and abs() function in one module not diagnosed

2009-06-18 Thread ivan dot glushkov at gmail dot com


--- Comment #2 from ivan dot glushkov at gmail dot com  2009-06-18 09:48 
---
Why invalid? And why non-static is not invalid?
Can you please give me reference to documentation where it's described?


-- 


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