-fvisibility=hidden vs. typeinfo

Jonathan Wakely jwakely.gcc@gmail.com
Mon Jun 29 10:03:00 GMT 2015


On 29 June 2015 at 10:49, Avi Kivity <avi@cloudius-systems.com> wrote:
> On 06/29/2015 12:33 PM, Jonathan Wakely wrote:
>>
>> On 29 June 2015 at 09:58, Avi Kivity wrote:
>>>
>>> I have some code that looks like
>>>
>>>    void some_function() throw (std::out_of_range) {
>>>        ... call to std::map<>::at() which throws out_out_range
>>>    }
>>>
>>> if I compile with -fvisibility=hidden, this code calls terminate(). My
>>> suspicion is that I ended up with two copies of the typeinfo block for
>>> std::out_of_range; one used by std::__throw_out_of_range() in libstdc++,
>>> and
>>> another in the guard code generated by the compiler.  Since they don't
>>> match, the guard block terminates.
>>>
>>> Is this correct?  If so, is this a bug in libstdc++, or the compiler (or
>>> the
>>> linker)?  If not, what can I do to fix this?
>>>
>>> I wasn't able to generate a self contained test case quickly, but if
>>> there's
>>> no other way, I'll invest more effort into it.
>>
>> I think this is supposed to work, because type matching should be done
>> using typeinfo names not just the identity of the typeinfo obejcts.
>
>
> Does that work for derived exceptions as well?  e.g.
>
> void f() throw (foo) {
>   try {
>      throw(bar());
>   } catch (bar&) {
>      std::throw_with_nested(foo());
>   }
> }

I hope so.

> I'll try to reduce the testcase I have.



More information about the Gcc-help mailing list