This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
weak-attribute over-optimisation with 4.1
- From: Jan Kiszka <jan dot kiszka at web dot de>
- To: gcc-help at gcc dot gnu dot org
- Date: Sat, 20 May 2006 19:48:43 +0200
- Subject: 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.