[Bug c++/33925] gcc -Waddress lost some useful warnings

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Apr 18 17:04:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33925

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-04-18 17:01:23 UTC ---
(In reply to comment #3)
> First, I think the C++ standard forbids a function from having a null 
> address:

But GCC extensions allow it, see the weakref attribute:

http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html#index-g_t_0040code_007bweakref_007d-attribute-2648

That's used (among other places) by GCC's pthreads abstraction layer to declare
a weak alias to pthread_create, which has a null address unless libpthread is
linked to.  Testing whether the address is null (i.. whether the application
was linked to libpthread) is used for important optimisations.



More information about the Gcc-bugs mailing list