------- Comment #4 from trini at kernel dot crashing dot org  2006-06-01 18:36 
-------
(In reply to comment #3)
> Actually no, you have to use -fPIC to get this not to be optimized, otherwise
> func will be bound locally which is not what you want.

Two things.  First, that's a change in behavior from how it used to work and I
don't recall seeing warnings about going-away behavior (the place this problem
is actually manifesting is in code for the Linux Kernel).

Second there is some sort of bug here as if we have:
$ cat file-a.c
void __attribute__((weak)) func(void)
{
        printf("weak\n");
}

main()
{
            func();
}
$ cat file-b.c
void func(void)
{
        printf("func\n");
}
$ gcc-4.1 -c file-a.c file-b.c -O2
file-a.c: In function 'func':
file-a.c:3: warning: incompatible implicit declaration of built-in function
'printf'
file-b.c: In function 'func':
file-b.c:3: warning: incompatible implicit declaration of built-in function
'printf'
$ gcc-4.1 -o program file-a.o file-b.o
$ ./program
func
$ gcc-4.1 -o program file-a.o
$ ./program
weak
$ gcc-4.1 -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,java,fortran,objc,obj-c++,ada,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu
--enable-libstdcxx-debug --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.1-1.4.2.0/jre --enable-mpfr
--enable-checking=release x86_64-linux-gnu
Thread model: posix
gcc version 4.1.0 (Debian 4.1.0-1)


-- 

trini at kernel dot crashing dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |trini at kernel dot crashing
                   |                            |dot org


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

Reply via email to