Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
GLOBAL_BAD_TYPEID.cpp
Go to the documentation of this file.
1// checking for class ::bad_typeid
2
3
25#include "config.h"
26
27
28#ifndef _RWSTD_NO_TYPEINFO
29# include <typeinfo>
30#else // if defined (_RWSTD_NO_TYPEINFO)
31# ifndef _RWSTD_NO_TYPEINFO_H
32# include <typeinfo.h>
33# else // if defined (_RWSTD_NO_TYPEINFO_H)
34
35// 5.2.8, p6: using typeid() without #including <typeinfo>
36// first yields undefined behavior...
37
38class bad_typeid { };
39
40# endif // _RWSTD_NO_TYPEINFO_H
41#endif // _RWSTD_NO_TYPEINFO
42
43
44#if 2 == __GNUG__
45# ifndef _RWSTD_NO_HONOR_STD
46# ifdef _RWSTD_NO_STD_TERMINATE
47# include "terminate.h"
48# endif // _RWSTD_NO_STD_TERMINATE
49# endif // _RWSTD_NO_HONOR_STD
50#endif // gcc 2.x
51
52
53struct S { virtual ~S () { } };
54
55int main ()
56{
57 try {
58 S *s = 0;
59
60 // expected to throw [std::] bad_typeid
61 typeid (*s);
62 }
63 catch (bad_typeid&) {
64 return 0;
65 }
66 catch (...) {
67 // fail if typeid throws anything other than a std::bad_typeid
68 return 1;
69 }
70
71 // fail if typeid doesn't throw
72 return 2;
73}
#define s
int main()
bad_typeid
virtual ~S()