This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: bad_cast
- To: egcs mailing list <egcs at cygnus dot com>
- Subject: Re: bad_cast
- From: Thomas Kunert <kunert at physik dot tu-dresden dot de>
- Date: Tue, 28 Jul 1998 16:48:08 +0200
- Organization: TU Dresden
Nyny wrote:
>
> Hi,
>
> I can not find the bad_cast exception in any header.
> I'm using snapshot 19980707.
> According to the dec96 draft of the standard, still cannot
> get a newer one ~:-(
> in clause 5.2.7
> 9 The value of a failed cast to pointer type is the null pointer value
> of the required result type. A failed cast to reference type throws
> bad_cast (18.5.2).
Hi Nyny,
Don't worry about the position of the header files, just try if the
*compiler* finds them. Have you ever asked it about that? Try the
following program.
#include <iostream>
#include <typeinfo>
class A {
public:
virtual ~A(){}
};
class B : public A {};
int main()
{
A a;
try {
dynamic_cast<B&>(a);
} catch (bad_cast) {
cout << "successfully caught!" << endl;
}
}
That proves the presence of class bad_cast.
Just for the curious:
The header <typeinfo> is to be found in .../lib/gcc-lib/.../include .
--
Thomas Kunert