This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Does weak work on PPC with -O2?
- To: "H . J . Lu" <hjl at gnu dot org>
- Subject: Re: Does weak work on PPC with -O2?
- From: Geoff Keating <geoffk at geoffk dot org>
- Date: 11 Mar 2001 20:45:48 -0800
- CC: gcc-bugs at gcc dot gnu dot org
- References: <20010311154432.A32325@gnu.org>
"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>