Aliases ...

Roland McGrath roland@redhat.com
Fri Jan 14 18:56:00 GMT 2005


> Roland McGrath <roland@redhat.com> writes:
> 
> >> Here's a patch to initialize it - it removes the warning.
> >
> > This really happens with __thread?  The right thing when this issue comes
> > up is to use __attribute__((nocommon)).
> 
> 
> This test case does indeed warn:
> 
>  __thread int errno __attribute__ ((nocommon));
> extern __thread int __libc_errno __attribute__ ((alias ("errno")));
> 
> with:
> test.i:2: warning: $,1rx(B__libc_errno$,1ry(B aliased to undefined symbol $,1rx(Berrno$,1ry
(B> 
> Initialising it to 0 fixes it,

Of course __attribute__ ((nocommon)) isn't meaningful with __thread.
__thread variables are never commons.  The question is why there is a
warning in the first place here.  AFAIK, there is no problem with an
uninitialized __thread variable getting an alias, except in the compiler's
mind.  



More information about the Libc-hacker mailing list