followups to your visibility work

Mark Mitchell mark@codesourcery.com
Mon Aug 9 02:51:00 GMT 2004


Niall Douglas wrote:

>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>On 5 Aug 2004 at 16:56, Mark Mitchell wrote:
>
>  
>
>>>One point - you probably still want the check & ignore of non default
>>>visibility on global operator new and delete. If code defines this
>>>with non-default visibility you get a segfault in GNU ld at link
>>>time. And it's very easy to do this accidentally if you use -
>>>-fvisibility=hidden.
>>>
>>>      
>>>
>>Because those are library functions, it should be impossible to do as
>>you say; they are created with DECL_VISIBILITY set to
>>VISIBILITY_DEFAULT and with DECL_VISIBILITY_SPECIFIED set.
>>    
>>
>
>Well, you'd have thought that wouldn't you? However it doesn't work 
>like that. As the ISO C++ standard permits, a program can redefine 
>global operator new and delete (as my library TnFOX does). 
>  
>
Yes, the ISO standard permits you to redefine operator new.  However, it 
does not permit you to define it as a "hidden" function -- because it 
doesn't talk about such things at all.  The closest analog is that it 
does not allow you to define it as a "static" function.  It's sensible, 
then, to disallow defining it as a hidden function, either.  That is 
what my patch does, assuming it does not have a bug; I do not believe 
you can define "operator new" as a hidden function in the current 
version of the compiler.

If you can, and the linker crashes, that is both a compiler bug (in my 
patch) and a linker bug (due to the crash).

-- 
Mark Mitchell
CodeSourcery, LLC
(916) 791-8304
mark@codesourcery.com



More information about the Gcc-patches mailing list