This is the mail archive of the gcc-bugs@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]

Re: Does weak work on PPC with -O2?


On Sun, Mar 11, 2001 at 08:45:48PM -0800, Geoff Keating wrote:
> "H . J . Lu" <hjl@gnu.org> writes:
> 
> > extern void *foo __attribute__ ((__weak__));
> > 
> >   printf ("foo: %p\n", &foo == NULL ? NULL : foo);
> 
> This is a known problem in GCC.  It only works on ia32 by accident.
> GCC does not believe that a reference like 'foo' can trap.
> 
> The responsible code is rtx_addr_can_trap_p in rtlanal.c.  You can see
> in the current version a comment explaining that it's wrong but it would
> be a large deoptimisation to fix in the obvious way.
> 
> In general, it's better to avoid undefined weak symbols; instead, provide
> weak stub definitions.
> 

Well, undefined weak symbol has a well defined semantics. Glibc
uses undefined weak symbol. I don't believe glibc is the only
package which uses it. It sounds a serious bug to me. Fortunately,
it works on ia32 "by accident".

BTW, if gcc cannot do it right, shouldn't it issue a warning instead
of generating incorrect code?


H.J.


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