Frage zu GCCs __dynamic_cast, wie man `Whole_prefix-> Whole_type! = Whole_type` klickt?C++

Programme in C++. Entwicklerforum
Anonymous
 Frage zu GCCs __dynamic_cast, wie man `Whole_prefix-> Whole_type! = Whole_type` klickt?

Post by Anonymous »

Während der Erforschung __dynamic_cast (GCC-Implementierung von dynamic_cast ) bin ich auf den folgenden Code gestoßen:

Code: Select all

  // If the whole object vptr doesn't refer to the whole object type, we're
// in the middle of constructing a primary base, and src is a separate
// base.  This has undefined behavior and we can't find anything outside
// of the base we're actually constructing, so fail now rather than
// segfault later trying to use a vbase offset that doesn't exist.
const void *whole_vtable = *static_cast  (whole_ptr);
const vtable_prefix *whole_prefix =
(adjust_pointer 
(whole_vtable, -ptrdiff_t (offsetof (vtable_prefix, origin))));
if (whole_prefix->whole_type != whole_type)
return NULL;
und ich fanden das Komitee, das diesem Patch entspricht:
https://patchwork.ozlabs.org/project/gc ... edhat.com/
Was für ein Kommentar. Das gleiche. Whole_type ?
Ich habe mein Bestes versucht, verschiedene Szenarien auszuprobieren, aber ohne Erfolg. Kann jemand ein geeignetes Beispiel geben?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post