Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
TYPE_INFO_DTOR.cpp
Go to the documentation of this file.
1// checking for type_info dtor
2
3
25#include "config.h"
26
27
28#ifndef _RWSTD_NO_HONOR_STD
29# ifdef _RWSTD_NO_STD_TERMINATE
30# include "terminate.h"
31# endif // _RWSTD_NO_STD_TERMINATE
32#endif // _RWSTD_NO_HONOR_STD
33
34
35#ifndef _RWSTD_NO_STD_TYPE_INFO
36# define NAMESPACE(name) namespace name
37#else
38# ifndef _RWSTD_NO_GLOBAL_TYPE_INFO
39# define NAMESPACE(ignore) extern "C++"
40# define std /* empty */
41# else
42# ifndef _RWSTD_NO_RUNTIME_IN_STD
43# define NAMESPACE(name) namespace name
44# else
45# define NAMESPACE(ignore) extern "C++"
46# define std /* empty */
47# endif // _RWSTD_NO_RUNTIME_IN_STD
48# endif // _RWSTD_NO_GLOBAL_TYPE_INFO
49#endif // _RWSTD_NO_STD_TYPE_INFO
50
51
53
54
55#if defined (__EDG__) || defined (__sgi)
56 // let edg (or some of its derivatives) know about this fake type_info
57# if !defined (__GNUG__) && !defined (__INTEL_COMPILER)
58# pragma define_type_info
59# endif
60#endif // __EDG__
61
62
63struct type_info
64{
65 virtual ~type_info ();
66};
67
68
69} // namespace std
70
71
72struct B0: virtual std::type_info { };
73struct B1: virtual std::type_info { };
74
75struct Derived: B0, B1
76{
77 virtual ~Derived ();
78};
79
80
81int dtor;
82
83int main (int argc, char *argv[])
84{
85 // avoid executing the body of main unless explicitly requested
86 // by specifying at least one command line argument (this foils
87 // aggressive optimizers from eliminating the code)
88 (void)&argv;
89 if (argc < 2)
90 return 0;
91
92 // try to prevent the compiler from optimizing the dtor call away
94
95 if (1 < argc)
96 ptr = (std::type_info*)argv[2];
97 else
98 ptr = (Derived*)argv[1];
99
100 // this will most like crash if evaluated but under normal
101 // conditions the function should never reach this far
102 delete ptr;
103
104 return !(1 < argc ? 1 == dtor : 0 == dtor);
105}
106
107
108Derived::~Derived () { ++dtor; }
#define ptr
Definition 17.names.cpp:525
#define main
int dtor
#define NAMESPACE(name)
Definition json.h:5363
virtual ~Derived()