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

Louis Dionne via libcxx-dev libcxx-dev at lists.llvm.org
Mon Oct 22 05:58:39 PDT 2018



> 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 <mailto: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.

Louis

>  
> > -----Original Message-----
> > From: libcxx-dev <libcxx-dev-bounces at lists.llvm.org <mailto:libcxx-dev-bounces at lists.llvm.org>> On Behalf Of Louis
> > Dionne via libcxx-dev
> > Sent: Wednesday, October 17, 2018 1:33 PM
> > To: libcxx-dev at lists.llvm.org <mailto:libcxx-dev at lists.llvm.org>
> > Subject: [libcxx-dev] Question: Why are std::exception & friends not in a
> > versioned namespace?
> > 
> > The title of the message pretty much says everything. I’m wondering why
> > `std::exception` is not `std::__1::exception` instead — most symbols are in
> > the  versioned namespace, but not this one.
> > 
> > Thanks,
> > Louis
> > 
> > _______________________________________________
> > libcxx-dev mailing list
> > libcxx-dev at lists.llvm.org <mailto:libcxx-dev at lists.llvm.org>
> > https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi- <https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi->
> > 2Dbin_mailman_listinfo_libcxx-
> > 2Ddev&d=DwIGaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=y8
> > mub81SfUi-UCZRX0Vl1g&m=SXXSmQhIwn-A25pzcb_sggzAo2-eOJsf6qXxNo-
> > nK0Y&s=CmmWD_6xN8H21UexX902giBa7RN0TM7POgqsYXG34VA&e=
> _______________________________________________
> libcxx-dev mailing list
> libcxx-dev at lists.llvm.org <mailto:libcxx-dev at lists.llvm.org>
> http://lists.llvm.org/cgi-bin/mailman/listinfo/libcxx-dev <http://lists.llvm.org/cgi-bin/mailman/listinfo/libcxx-dev>

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


More information about the libcxx-dev mailing list