This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc 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]

Re: Miscompilation of glibc with CVS mainline


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




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]