Remy Porter’s Daily WTF article, dated 2026-10-12, examines an anonymized C++ example associated with Alan. Porter says the codebase was written by developers with an uncertain grasp of core object-oriented concepts. He also criticizes biological-taxonomy analogies that can make inheritance seem more important than it is.
#define IS_INSTANCE_OF(objectPointer, className) ((bool) (dynamic_cast<className *>(((Organism *) objectPointer)) != NULL))
#define IS_MEMBER_OF(objectPointer, className) IS_INSTANCE_OF(objectPointer, className)Animal::StealTentacle(Animal *animal) accepts a raw Animal* pointer. It returns unless this is an Octopus or Squid. The method then calls animal->mLimbs->GetFirstTentacle() and, when it receives a Limb, invokes limb->AttachToAnimal(this).
IS_INSTANCE_OF implements the restriction. The macro uses a C-style cast to turn objectPointer into Organism* before passing it to dynamic_cast<className*> and checking for NULL. In C++, such a cast can make the compiler choose progressively broader cast mechanisms, potentially reaching reinterpret_cast, which discards type information. IS_MEMBER_OF is a temporary alias.
The macro’s comment claims that dynamic_cast always succeeds for the supplied pointer type and suggests Organism as a workaround. Porter says that interpretation is wrong. A failed dynamic_cast returns NULL, but the operator can also crosscast between sibling branches with a common public base. A Dog* conversion from a Cat* can succeed when the most-derived object contains both subobjects.
Callers then write IS_INSTANCE_OF(animal, Felid) and apply another C-style cast to Felid*. A nearby comment admits uncertainty about whether the conversion does what its author expects. Porter calls this a type-switch anti-pattern. He argues that polymorphism and the type system should express the restriction. Careful dynamic dispatch can model a domain cleanly. The article cites Bjarne Stroustrup’s The Design and Evolution of C++, which warns that RTTI can also enable code that bypasses those language facilities and produces a poor compromise between C-like syntax and Smalltalk-like runtime behavior.




Comments
No comments yet — be the first.
Open the discussion
No account or password needed — just enter your e-mail and we’ll send you a one-time sign-in link. First time here? You’re set up automatically.
Your rating will be applied automatically after you sign in.
Check your inbox
We’ve sent a sign-in link to …. Open it on this device — this tab will sign you in automatically.
Nothing arrived? Check your spam folder — and mark the mail as "Not spam" so it lands in your inbox next time.