public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/40485]  New: definitions of __builtin_abs() and abs() function in one module
@ 2009-06-18  9:20 ivan dot glushkov at gmail dot com
  2009-06-18  9:36 ` [Bug c/40485] definitions of __builtin_abs() and abs() function in one module not diagnosed rguenth at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: ivan dot glushkov at gmail dot com @ 2009-06-18  9:20 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-06-21 22:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-18  9:20 [Bug c/40485] New: definitions of __builtin_abs() and abs() function in one module ivan dot glushkov at gmail dot com
2009-06-18  9:36 ` [Bug c/40485] definitions of __builtin_abs() and abs() function in one module not diagnosed rguenth at gcc dot gnu dot org
2009-06-18  9:48 ` ivan dot glushkov at gmail dot com
2009-06-18 13:48 ` rguenth at gcc dot gnu dot org
2009-06-18 14:51 ` pinskia at gcc dot gnu dot org
2009-06-18 21:09 ` joseph at codesourcery dot com
2009-06-21 22:46 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).