This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

weak-attribute over-optimisation with 4.1


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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]