]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/libsupc++/tinfo.cc
new: Remove pragma interface.
[thirdparty/gcc.git] / libstdc++-v3 / libsupc++ / tinfo.cc
1 // Methods for type_info for -*- C++ -*- Run Time Type Identification.
2 // Copyright (C) 1994, 1996, 1998, 1999, 2000, 2001 Free Software Foundation
3 //
4 // This file is part of GNU CC.
5 //
6 // GNU CC is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2, or (at your option)
9 // any later version.
10
11 // GNU CC is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15
16 // You should have received a copy of the GNU General Public License
17 // along with GNU CC; see the file COPYING. If not, write to
18 // the Free Software Foundation, 59 Temple Place - Suite 330,
19 // Boston, MA 02111-1307, USA.
20
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
29
30 #include <cstddef>
31 #include "tinfo.h"
32 #include "new" // for placement new
33
34 // This file contains the minimal working set necessary to link with code
35 // that uses virtual functions and -frtti but does not actually use RTTI
36 // functionality.
37
38 std::type_info::
39 ~type_info ()
40 { }
41
42 std::bad_cast::~bad_cast() throw() { }
43 std::bad_typeid::~bad_typeid() throw() { }
44
45 #if !__GXX_MERGED_TYPEINFO_NAMES
46
47 // We can't rely on common symbols being shared between shared objects.
48 bool std::type_info::
49 operator== (const std::type_info& arg) const
50 {
51 return (&arg == this) || (__builtin_strcmp (name (), arg.name ()) == 0);
52 }
53
54 #endif
55
56 namespace std {
57
58 // return true if this is a type_info for a pointer type
59 bool type_info::
60 __is_pointer_p () const
61 {
62 return false;
63 }
64
65 // return true if this is a type_info for a function type
66 bool type_info::
67 __is_function_p () const
68 {
69 return false;
70 }
71
72 // try and catch a thrown object.
73 bool type_info::
74 __do_catch (const type_info *thr_type, void **, unsigned) const
75 {
76 return *this == *thr_type;
77 }
78
79 // upcast from this type to the target. __class_type_info will override
80 bool type_info::
81 __do_upcast (const abi::__class_type_info *, void **) const
82 {
83 return false;
84 }
85
86 };
87
88 namespace {
89
90 using namespace std;
91 using namespace abi;
92
93 // initial part of a vtable, this structure is used with offsetof, so we don't
94 // have to keep alignments consistent manually.
95 struct vtable_prefix {
96 ptrdiff_t whole_object; // offset to most derived object
97 const __class_type_info *whole_type; // pointer to most derived type_info
98 const void *origin; // what a class's vptr points to
99 };
100
101 template <typename T>
102 inline const T *
103 adjust_pointer (const void *base, ptrdiff_t offset)
104 {
105 return reinterpret_cast <const T *>
106 (reinterpret_cast <const char *> (base) + offset);
107 }
108
109 // ADDR is a pointer to an object. Convert it to a pointer to a base,
110 // using OFFSET. IS_VIRTUAL is true, if we are getting a virtual base.
111 inline void const *
112 convert_to_base (void const *addr, bool is_virtual, ptrdiff_t offset)
113 {
114 if (is_virtual)
115 {
116 const void *vtable = *static_cast <const void *const *> (addr);
117
118 offset = *adjust_pointer<ptrdiff_t> (vtable, offset);
119 }
120
121 return adjust_pointer<void> (addr, offset);
122 }
123
124 // some predicate functions for __class_type_info::__sub_kind
125 inline bool contained_p (__class_type_info::__sub_kind access_path)
126 {
127 return access_path >= __class_type_info::__contained_mask;
128 }
129 inline bool public_p (__class_type_info::__sub_kind access_path)
130 {
131 return access_path & __class_type_info::__contained_public_mask;
132 }
133 inline bool virtual_p (__class_type_info::__sub_kind access_path)
134 {
135 return (access_path & __class_type_info::__contained_virtual_mask);
136 }
137 inline bool contained_public_p (__class_type_info::__sub_kind access_path)
138 {
139 return ((access_path & __class_type_info::__contained_public)
140 == __class_type_info::__contained_public);
141 }
142 inline bool contained_nonpublic_p (__class_type_info::__sub_kind access_path)
143 {
144 return ((access_path & __class_type_info::__contained_public)
145 == __class_type_info::__contained_mask);
146 }
147 inline bool contained_nonvirtual_p (__class_type_info::__sub_kind access_path)
148 {
149 return ((access_path & (__class_type_info::__contained_mask
150 | __class_type_info::__contained_virtual_mask))
151 == __class_type_info::__contained_mask);
152 }
153
154 static const __class_type_info *const nonvirtual_base_type =
155 static_cast <const __class_type_info *> (0) + 1;
156
157 }; // namespace
158
159 namespace __cxxabiv1
160 {
161
162 __class_type_info::
163 ~__class_type_info ()
164 {}
165
166 __si_class_type_info::
167 ~__si_class_type_info ()
168 {}
169
170 __vmi_class_type_info::
171 ~__vmi_class_type_info ()
172 {}
173
174 // __upcast_result is used to hold information during traversal of a class
175 // heirarchy when catch matching.
176 struct __class_type_info::__upcast_result
177 {
178 const void *dst_ptr; // pointer to caught object
179 __sub_kind part2dst; // path from current base to target
180 int src_details; // hints about the source type heirarchy
181 const __class_type_info *base_type; // where we found the target,
182 // if in vbase the __class_type_info of vbase
183 // if a non-virtual base then 1
184 // else NULL
185 public:
186 __upcast_result (int d)
187 :dst_ptr (NULL), part2dst (__unknown), src_details (d), base_type (NULL)
188 {}
189 };
190
191 // __dyncast_result is used to hold information during traversal of a class
192 // heirarchy when dynamic casting.
193 struct __class_type_info::__dyncast_result
194 {
195 const void *dst_ptr; // pointer to target object or NULL
196 __sub_kind whole2dst; // path from most derived object to target
197 __sub_kind whole2src; // path from most derived object to sub object
198 __sub_kind dst2src; // path from target to sub object
199 int whole_details; // details of the whole class heirarchy
200
201 public:
202 __dyncast_result (int details_ = __vmi_class_type_info::__flags_unknown_mask)
203 :dst_ptr (NULL), whole2dst (__unknown),
204 whole2src (__unknown), dst2src (__unknown),
205 whole_details (details_)
206 {}
207 };
208
209 bool __class_type_info::
210 __do_catch (const type_info *thr_type,
211 void **thr_obj,
212 unsigned outer) const
213 {
214 if (*this == *thr_type)
215 return true;
216 if (outer >= 4)
217 // Neither `A' nor `A *'.
218 return false;
219 return thr_type->__do_upcast (this, thr_obj);
220 }
221
222 bool __class_type_info::
223 __do_upcast (const __class_type_info *dst_type,
224 void **obj_ptr) const
225 {
226 __upcast_result result (__vmi_class_type_info::__flags_unknown_mask);
227
228 __do_upcast (dst_type, *obj_ptr, result);
229 if (!contained_public_p (result.part2dst))
230 return false;
231 *obj_ptr = const_cast <void *> (result.dst_ptr);
232 return true;
233 }
234
235 inline __class_type_info::__sub_kind __class_type_info::
236 __find_public_src (ptrdiff_t src2dst,
237 const void *obj_ptr,
238 const __class_type_info *src_type,
239 const void *src_ptr) const
240 {
241 if (src2dst >= 0)
242 return adjust_pointer <void> (obj_ptr, src2dst) == src_ptr
243 ? __contained_public : __not_contained;
244 if (src2dst == -2)
245 return __not_contained;
246 return __do_find_public_src (src2dst, obj_ptr, src_type, src_ptr);
247 }
248
249 __class_type_info::__sub_kind __class_type_info::
250 __do_find_public_src (ptrdiff_t,
251 const void *obj_ptr,
252 const __class_type_info *,
253 const void *src_ptr) const
254 {
255 if (src_ptr == obj_ptr)
256 // Must be our type, as the pointers match.
257 return __contained_public;
258 return __not_contained;
259 }
260
261 __class_type_info::__sub_kind __si_class_type_info::
262 __do_find_public_src (ptrdiff_t src2dst,
263 const void *obj_ptr,
264 const __class_type_info *src_type,
265 const void *src_ptr) const
266 {
267 if (src_ptr == obj_ptr && *this == *src_type)
268 return __contained_public;
269 return __base_type->__do_find_public_src (src2dst, obj_ptr, src_type, src_ptr);
270 }
271
272 __class_type_info::__sub_kind __vmi_class_type_info::
273 __do_find_public_src (ptrdiff_t src2dst,
274 const void *obj_ptr,
275 const __class_type_info *src_type,
276 const void *src_ptr) const
277 {
278 if (obj_ptr == src_ptr && *this == *src_type)
279 return __contained_public;
280
281 for (std::size_t i = __base_count; i--;)
282 {
283 if (!__base_info[i].__is_public_p ())
284 continue; // Not public, can't be here.
285
286 const void *base = obj_ptr;
287 ptrdiff_t offset = __base_info[i].__offset ();
288 bool is_virtual = __base_info[i].__is_virtual_p ();
289
290 if (is_virtual)
291 {
292 if (src2dst == -3)
293 continue; // Not a virtual base, so can't be here.
294 }
295 base = convert_to_base (base, is_virtual, offset);
296
297 __sub_kind base_kind = __base_info[i].__base->__do_find_public_src
298 (src2dst, base, src_type, src_ptr);
299 if (contained_p (base_kind))
300 {
301 if (is_virtual)
302 base_kind = __sub_kind (base_kind | __contained_virtual_mask);
303 return base_kind;
304 }
305 }
306
307 return __not_contained;
308 }
309
310 bool __class_type_info::
311 __do_dyncast (ptrdiff_t,
312 __sub_kind access_path,
313 const __class_type_info *dst_type,
314 const void *obj_ptr,
315 const __class_type_info *src_type,
316 const void *src_ptr,
317 __dyncast_result &__restrict result) const
318 {
319 if (obj_ptr == src_ptr && *this == *src_type)
320 {
321 // The src object we started from. Indicate how we are accessible from
322 // the most derived object.
323 result.whole2src = access_path;
324 return false;
325 }
326 if (*this == *dst_type)
327 {
328 result.dst_ptr = obj_ptr;
329 result.whole2dst = access_path;
330 result.dst2src = __not_contained;
331 return false;
332 }
333 return false;
334 }
335
336 bool __si_class_type_info::
337 __do_dyncast (ptrdiff_t src2dst,
338 __sub_kind access_path,
339 const __class_type_info *dst_type,
340 const void *obj_ptr,
341 const __class_type_info *src_type,
342 const void *src_ptr,
343 __dyncast_result &__restrict result) const
344 {
345 if (*this == *dst_type)
346 {
347 result.dst_ptr = obj_ptr;
348 result.whole2dst = access_path;
349 if (src2dst >= 0)
350 result.dst2src = adjust_pointer <void> (obj_ptr, src2dst) == src_ptr
351 ? __contained_public : __not_contained;
352 else if (src2dst == -2)
353 result.dst2src = __not_contained;
354 return false;
355 }
356 if (obj_ptr == src_ptr && *this == *src_type)
357 {
358 // The src object we started from. Indicate how we are accessible from
359 // the most derived object.
360 result.whole2src = access_path;
361 return false;
362 }
363 return __base_type->__do_dyncast (src2dst, access_path, dst_type, obj_ptr,
364 src_type, src_ptr, result);
365 }
366
367 // This is a big hairy function. Although the run-time behaviour of
368 // dynamic_cast is simple to describe, it gives rise to some non-obvious
369 // behaviour. We also desire to determine as early as possible any definite
370 // answer we can get. Because it is unknown what the run-time ratio of
371 // succeeding to failing dynamic casts is, we do not know in which direction
372 // to bias any optimizations. To that end we make no particular effort towards
373 // early fail answers or early success answers. Instead we try to minimize
374 // work by filling in things lazily (when we know we need the information),
375 // and opportunisticly take early success or failure results.
376 bool __vmi_class_type_info::
377 __do_dyncast (ptrdiff_t src2dst,
378 __sub_kind access_path,
379 const __class_type_info *dst_type,
380 const void *obj_ptr,
381 const __class_type_info *src_type,
382 const void *src_ptr,
383 __dyncast_result &__restrict result) const
384 {
385 if (result.whole_details & __flags_unknown_mask)
386 result.whole_details = __flags;
387
388 if (obj_ptr == src_ptr && *this == *src_type)
389 {
390 // The src object we started from. Indicate how we are accessible from
391 // the most derived object.
392 result.whole2src = access_path;
393 return false;
394 }
395 if (*this == *dst_type)
396 {
397 result.dst_ptr = obj_ptr;
398 result.whole2dst = access_path;
399 if (src2dst >= 0)
400 result.dst2src = adjust_pointer <void> (obj_ptr, src2dst) == src_ptr
401 ? __contained_public : __not_contained;
402 else if (src2dst == -2)
403 result.dst2src = __not_contained;
404 return false;
405 }
406
407 bool result_ambig = false;
408 for (std::size_t i = __base_count; i--;)
409 {
410 __dyncast_result result2 (result.whole_details);
411 void const *base = obj_ptr;
412 __sub_kind base_access = access_path;
413 ptrdiff_t offset = __base_info[i].__offset ();
414 bool is_virtual = __base_info[i].__is_virtual_p ();
415
416 if (is_virtual)
417 base_access = __sub_kind (base_access | __contained_virtual_mask);
418 base = convert_to_base (base, is_virtual, offset);
419
420 if (!__base_info[i].__is_public_p ())
421 {
422 if (src2dst == -2 &&
423 !(result.whole_details
424 & (__non_diamond_repeat_mask | __diamond_shaped_mask)))
425 // The hierarchy has no duplicate bases (which might ambiguate
426 // things) and where we started is not a public base of what we
427 // want (so it cannot be a downcast). There is nothing of interest
428 // hiding in a non-public base.
429 continue;
430 base_access = __sub_kind (base_access & ~__contained_public_mask);
431 }
432
433 bool result2_ambig
434 = __base_info[i].__base->__do_dyncast (src2dst, base_access,
435 dst_type, base,
436 src_type, src_ptr, result2);
437 result.whole2src = __sub_kind (result.whole2src | result2.whole2src);
438 if (result2.dst2src == __contained_public
439 || result2.dst2src == __contained_ambig)
440 {
441 result.dst_ptr = result2.dst_ptr;
442 result.whole2dst = result2.whole2dst;
443 result.dst2src = result2.dst2src;
444 // Found a downcast which can't be bettered or an ambiguous downcast
445 // which can't be disambiguated
446 return result2_ambig;
447 }
448
449 if (!result_ambig && !result.dst_ptr)
450 {
451 // Not found anything yet.
452 result.dst_ptr = result2.dst_ptr;
453 result.whole2dst = result2.whole2dst;
454 result_ambig = result2_ambig;
455 if (result.dst_ptr && result.whole2src != __unknown
456 && !(__flags & __non_diamond_repeat_mask))
457 // Found dst and src and we don't have repeated bases.
458 return result_ambig;
459 }
460 else if (result.dst_ptr && result.dst_ptr == result2.dst_ptr)
461 {
462 // Found at same address, must be via virtual. Pick the most
463 // accessible path.
464 result.whole2dst =
465 __sub_kind (result.whole2dst | result2.whole2dst);
466 }
467 else if ((result.dst_ptr != 0 | result_ambig)
468 && (result2.dst_ptr != 0 | result2_ambig))
469 {
470 // Found two different DST_TYPE bases, or a valid one and a set of
471 // ambiguous ones, must disambiguate. See whether SRC_PTR is
472 // contained publicly within one of the non-ambiguous choices. If it
473 // is in only one, then that's the choice. If it is in both, then
474 // we're ambiguous and fail. If it is in neither, we're ambiguous,
475 // but don't yet fail as we might later find a third base which does
476 // contain SRC_PTR.
477
478 __sub_kind new_sub_kind = result2.dst2src;
479 __sub_kind old_sub_kind = result.dst2src;
480
481 if (contained_p (result.whole2src)
482 && (!virtual_p (result.whole2src)
483 || !(result.whole_details & __diamond_shaped_mask)))
484 {
485 // We already found SRC_PTR as a base of most derived, and
486 // either it was non-virtual, or the whole heirarchy is
487 // not-diamond shaped. Therefore if it is in either choice, it
488 // can only be in one of them, and we will already know.
489 if (old_sub_kind == __unknown)
490 old_sub_kind = __not_contained;
491 if (new_sub_kind == __unknown)
492 new_sub_kind = __not_contained;
493 }
494 else
495 {
496 if (old_sub_kind >= __not_contained)
497 ;// already calculated
498 else if (contained_p (new_sub_kind)
499 && (!virtual_p (new_sub_kind)
500 || !(__flags & __diamond_shaped_mask)))
501 // Already found inside the other choice, and it was
502 // non-virtual or we are not diamond shaped.
503 old_sub_kind = __not_contained;
504 else
505 old_sub_kind = dst_type->__find_public_src
506 (src2dst, result.dst_ptr, src_type, src_ptr);
507
508 if (new_sub_kind >= __not_contained)
509 ;// already calculated
510 else if (contained_p (old_sub_kind)
511 && (!virtual_p (old_sub_kind)
512 || !(__flags & __diamond_shaped_mask)))
513 // Already found inside the other choice, and it was
514 // non-virtual or we are not diamond shaped.
515 new_sub_kind = __not_contained;
516 else
517 new_sub_kind = dst_type->__find_public_src
518 (src2dst, result2.dst_ptr, src_type, src_ptr);
519 }
520
521 // Neither sub_kind can be contained_ambig -- we bail out early
522 // when we find those.
523 if (contained_p (__sub_kind (new_sub_kind ^ old_sub_kind)))
524 {
525 // Only on one choice, not ambiguous.
526 if (contained_p (new_sub_kind))
527 {
528 // Only in new.
529 result.dst_ptr = result2.dst_ptr;
530 result.whole2dst = result2.whole2dst;
531 result_ambig = false;
532 old_sub_kind = new_sub_kind;
533 }
534 result.dst2src = old_sub_kind;
535 if (public_p (result.dst2src))
536 return false; // Can't be an ambiguating downcast for later discovery.
537 if (!virtual_p (result.dst2src))
538 return false; // Found non-virtually can't be bettered
539 }
540 else if (contained_p (__sub_kind (new_sub_kind & old_sub_kind)))
541 {
542 // In both.
543 result.dst_ptr = NULL;
544 result.dst2src = __contained_ambig;
545 return true; // Fail.
546 }
547 else
548 {
549 // In neither publicly, ambiguous for the moment, but keep
550 // looking. It is possible that it was private in one or
551 // both and therefore we should fail, but that's just tough.
552 result.dst_ptr = NULL;
553 result.dst2src = __not_contained;
554 result_ambig = true;
555 }
556 }
557
558 if (result.whole2src == __contained_private)
559 // We found SRC_PTR as a private non-virtual base, therefore all
560 // cross casts will fail. We have already found a down cast, if
561 // there is one.
562 return result_ambig;
563 }
564
565 return result_ambig;
566 }
567
568 bool __class_type_info::
569 __do_upcast (const __class_type_info *dst, const void *obj,
570 __upcast_result &__restrict result) const
571 {
572 if (*this == *dst)
573 {
574 result.dst_ptr = obj;
575 result.base_type = nonvirtual_base_type;
576 result.part2dst = __contained_public;
577 return true;
578 }
579 return false;
580 }
581
582 bool __si_class_type_info::
583 __do_upcast (const __class_type_info *dst, const void *obj_ptr,
584 __upcast_result &__restrict result) const
585 {
586 if (__class_type_info::__do_upcast (dst, obj_ptr, result))
587 return true;
588
589 return __base_type->__do_upcast (dst, obj_ptr, result);
590 }
591
592 bool __vmi_class_type_info::
593 __do_upcast (const __class_type_info *dst, const void *obj_ptr,
594 __upcast_result &__restrict result) const
595 {
596 if (__class_type_info::__do_upcast (dst, obj_ptr, result))
597 return true;
598
599 int src_details = result.src_details;
600 if (src_details & __flags_unknown_mask)
601 src_details = __flags;
602
603 for (std::size_t i = __base_count; i--;)
604 {
605 __upcast_result result2 (src_details);
606 const void *base = obj_ptr;
607 ptrdiff_t offset = __base_info[i].__offset ();
608 bool is_virtual = __base_info[i].__is_virtual_p ();
609 bool is_public = __base_info[i].__is_public_p ();
610
611 if (!is_public && !(src_details & __non_diamond_repeat_mask))
612 // original cannot have an ambiguous base, so skip private bases
613 continue;
614
615 if (base)
616 base = convert_to_base (base, is_virtual, offset);
617
618 if (__base_info[i].__base->__do_upcast (dst, base, result2))
619 {
620 if (result2.base_type == nonvirtual_base_type && is_virtual)
621 result2.base_type = __base_info[i].__base;
622 if (contained_p (result2.part2dst) && !is_public)
623 result2.part2dst = __sub_kind (result2.part2dst & ~__contained_public_mask);
624
625 if (!result.base_type)
626 {
627 result = result2;
628 if (!contained_p (result.part2dst))
629 return true; // found ambiguously
630
631 if (result.part2dst & __contained_public_mask)
632 {
633 if (!(__flags & __non_diamond_repeat_mask))
634 return true; // cannot have an ambiguous other base
635 }
636 else
637 {
638 if (!virtual_p (result.part2dst))
639 return true; // cannot have another path
640 if (!(__flags & __diamond_shaped_mask))
641 return true; // cannot have a more accessible path
642 }
643 }
644 else if (result.dst_ptr != result2.dst_ptr)
645 {
646 // Found an ambiguity.
647 result.dst_ptr = NULL;
648 result.part2dst = __contained_ambig;
649 return true;
650 }
651 else if (result.dst_ptr)
652 {
653 // Ok, found real object via a virtual path.
654 result.part2dst
655 = __sub_kind (result.part2dst | result2.part2dst);
656 }
657 else
658 {
659 // Dealing with a null pointer, need to check vbase
660 // containing each of the two choices.
661 if (result2.base_type == nonvirtual_base_type
662 || result.base_type == nonvirtual_base_type
663 || !(*result2.base_type == *result.base_type))
664 {
665 // Already ambiguous, not virtual or via different virtuals.
666 // Cannot match.
667 result.part2dst = __contained_ambig;
668 return true;
669 }
670 result.part2dst
671 = __sub_kind (result.part2dst | result2.part2dst);
672 }
673 }
674 }
675 return result.part2dst != __unknown;
676 }
677
678 // this is the external interface to the dynamic cast machinery
679 extern "C" void *
680 __dynamic_cast (const void *src_ptr, // object started from
681 const __class_type_info *src_type, // type of the starting object
682 const __class_type_info *dst_type, // desired target type
683 ptrdiff_t src2dst) // how src and dst are related
684 {
685 const void *vtable = *static_cast <const void *const *> (src_ptr);
686 const vtable_prefix *prefix =
687 adjust_pointer <vtable_prefix> (vtable,
688 -offsetof (vtable_prefix, origin));
689 const void *whole_ptr =
690 adjust_pointer <void> (src_ptr, prefix->whole_object);
691 const __class_type_info *whole_type = prefix->whole_type;
692 __class_type_info::__dyncast_result result;
693
694 whole_type->__do_dyncast (src2dst, __class_type_info::__contained_public,
695 dst_type, whole_ptr, src_type, src_ptr, result);
696 if (!result.dst_ptr)
697 return NULL;
698 if (contained_public_p (result.dst2src))
699 // Src is known to be a public base of dst.
700 return const_cast <void *> (result.dst_ptr);
701 if (contained_public_p (__class_type_info::__sub_kind (result.whole2src & result.whole2dst)))
702 // Both src and dst are known to be public bases of whole. Found a valid
703 // cross cast.
704 return const_cast <void *> (result.dst_ptr);
705 if (contained_nonvirtual_p (result.whole2src))
706 // Src is known to be a non-public nonvirtual base of whole, and not a
707 // base of dst. Found an invalid cross cast, which cannot also be a down
708 // cast
709 return NULL;
710 if (result.dst2src == __class_type_info::__unknown)
711 result.dst2src = dst_type->__find_public_src (src2dst, result.dst_ptr,
712 src_type, src_ptr);
713 if (contained_public_p (result.dst2src))
714 // Found a valid down cast
715 return const_cast <void *> (result.dst_ptr);
716 // Must be an invalid down cast, or the cross cast wasn't bettered
717 return NULL;
718 }
719
720 }; // namespace __cxxabiv1