standards/175453: Catching C std::bad_cast doesn' t work in FreeBSD 9.1

David Chisnall theraven at FreeBSD.org
Sat Jan 26 18:54:35 UTC 2013


This is more complicated than the test case I have.  Simply calling __cxa_bad_cast() will trigger it.  The issue is related to symbol versioning: libcxxrt and libsupc++ have the wrong symbol version for a number of C++ classes (mea culpa) and so when the runtime library throws the exception it throws its version, but everything else is seeing the other version. 

David

On 26 Jan 2013, at 17:10, Eitan Adler wrote:

> The following reply was made to PR standards/175453; it has been noted by GNATS.
> 
> From: Eitan Adler <lists at eitanadler.com>
> To: bug-followup at freebsd.org, hongli at phusion.nl
> Cc:  
> Subject: Re: standards/175453: Catching C std::bad_cast doesn't work in
> FreeBSD 9.1
> Date: Sat, 26 Jan 2013 12:07:14 -0500
> 
> This bug is probably well understood by now, but here is a minimal
> testcase for it (no includes, as few C++ features as possible):
> 
>  extern "C++" {
>     namespace std {
>       class exception   {
>           const char* name() const     {
>    }
>      };
>            class bad_cast : public exception   {
>      };
>    }
>       }
>       class foo {
>    public:     virtual ~foo() {
>   }
>    };
>        class bar: public foo {
>    public:     int val;
>        bar(): val(123) {
>   }
>    };
>        static void cast_test(const foo &f) {
>        try {
>            const bar &b = dynamic_cast<const bar &>(f);
>        }
>    catch (const std::bad_cast &) {
>        }
>    }
>        int main() {
>        foo f;
>        cast_test(f);
>    }
> 
> 
> -- 
> Eitan Adler
> _______________________________________________
> freebsd-standards at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-standards
> To unsubscribe, send any mail to "freebsd-standards-unsubscribe at freebsd.org"

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/freebsd-standards/attachments/20130126/365aaf66/attachment.sig>


More information about the freebsd-standards mailing list