This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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


> > 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)


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