This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Miscompilation of glibc with CVS mainline
- From: "John David Anglin" <dave at hiauly1 dot hia dot nrc dot ca>
- To: martin at v dot loewis dot de ("Martin v. Löwis")
- Cc: jakub at redhat dot com, aj at suse dot de, gcc at gcc dot gnu dot org, libc-alpha at sources dot redhat dot com
- Date: Thu, 2 Jan 2003 13:51:48 -0500 (EST)
- Subject: Re: Miscompilation of glibc with CVS mainline
> > 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.
I can't seem to find where the standard says &weak_func is always
unequal to null. I thought the exact details of function
pointers were implementation defined. If the test is changed to
use a generic function pointer, then no such assumption is made
and the comparison is kept. The comparison is also present if
`__attribute__ ((weak))' is used.
The gcc-3.2 and 3.3 generated code have the comparison. I'll leave
it up to the language lawyers to determine whether the current 3.4
behavior is correct.
Dave
--
J. David Anglin dave.anglin@nrc.ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6605)