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 the call to func() was optimised out
during the compilation of file-a.c. This happens with -O2, but not when using
-fno-unit-at-a-time. First sighted in 4.1.
--
Summary: weak-attribute over-optimisation with 4.1
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jan dot kiszka at web dot de
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27781