weak-attribute over-optimisation with 4.1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I tracked down some problem with gcc-4.1 (opensuse 10.1, can't say yet
if it's a suse-specific issue). It can be reduced to the following:

file-a.c:
---------
void __attribute__((weak)) func(void)
{
    /* no code */
}

main()
{
    func();
}


file-b.c:
---------
void func(void)
{
    printf("func\n");
}


# gcc -c file-a.c file-b.c -O2
# gcc -o program file-a.o file-b.o

The program will not print "func", because during the compilation of
file-a.c the call to func() was optimised out. This happens with -O2,
but not when using -fno-unit-at-a-time (for kernel hackers: linux 2.6.15
does not suffer while 2.6.16 does, sigh). And I do not see this with a
gcc-4.0.2 (opensuse 10.0).

So, is this a regression? Does it also happen with vanilla 4.1?

Jan


PS: Please CC me on reply.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux