[libcxx-dev] Question: Why are std::exception & friends not in a versioned namespace?

Marshall Clow via libcxx-dev libcxx-dev at lists.llvm.org
Wed Oct 24 10:40:47 PDT 2018


On Mon, Oct 22, 2018 at 5:58 AM Louis Dionne via libcxx-dev <
libcxx-dev at lists.llvm.org> wrote:

> On Oct 19, 2018, at 3:18 PM, Richard Smith <richard at metafoo.co.uk> wrote:
>
> On Wed, 17 Oct 2018 at 11:44, Ben Craig via libcxx-dev <
> libcxx-dev at lists.llvm.org> wrote:
>
>> "Magic" types that the compiler / core language know about don't go in
>> the versioned namespace.
>>
>
> That certainly applies to things like std::type_info,
> std::initializer_list, and std::bad_alloc, but std::exception is not
> special in this regard.
>
> Rather, I think the reason we don't version std::exception is so that in
> code that mixes use of libc++ and libstdc++, one can throw an exception
> derived from std::exception using one library and catch it using the other
> library. (A special case of that: the default 'terminate' handler can print
> out details of the thrown exception if it's derived from std::exception,
> even if it's using the std::exception from a different stdlib.)
>
>
> That makes a lot of sense. This means we have an official or unofficial
> "contract" with libstdc++ not to put those symbols in a versioned namespace.
>

Right.
We (the libc++ maintainers and the libstdc++ maintainers) agree that it
would be nice to be able to mix code, and so we do this (and a couple other
things) to make it so. For example, the libc++ exception classes look
weird, but that's so they work like the libstdc++ ones.

-- Marshall
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/libcxx-dev/attachments/20181024/dfe8cfb7/attachment.html>


More information about the libcxx-dev mailing list