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?


"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.

-- 
- Geoffrey Keating <geoffk@geoffk.org>


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