Miscompilation of glibc with CVS mainline
"Martin v. Löwis"
martin@v.loewis.de
Thu Jan 2 17:47:00 GMT 2003
John David Anglin wrote:
>>As GCC is not told in any way that weak_func is actually weak, I think
>>it is glibc's fault.
>
>
> This is definitely a gcc problem. This is the code arising from
> Andreas' testcase for hppa-linux at -O2:
[...]
> We have completely lost the `if'. As a result, weak_func is always
> called.
It's not a gcc bug. weak_func is a function, so &weak_func is always
unequal to null - that is guaranteed by the C programming language.
That's why the compiler is entitled to eliminate the test, under the
as-if rule. If you want to declare a function whose address can be zero,
you need to declare it weak, using the relevant extension in GNU C.
Regards,
Martin
More information about the Libc-alpha
mailing list