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

Eitan Adler lists at eitanadler.com
Sat Jan 26 17:10:01 UTC 2013


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


More information about the freebsd-standards mailing list