• (nodebb)

    It's almost like they tried to invent reflection. You can query properties of the class to dynamically learn about the class.

    Serious brain damage there.

    The fact the OP tells us this idiom is used inconsistently everywhere suggests one "genius" had invented this at some prior job, brought it here, proselytized it to the unwashed mass of ordinary devs, most of whom never understood it well enough to use it right (or at least as rightly as such insanity could be used), then moved on to the next company & next project. Or was promoted to some executive manager of dev roles here and so was able to insist it be used, but not pay attention to how it was used.

  • (nodebb)

    Now, I know that they are running with RTTI enabled, and thus when they do a bad cast, dynamic_cast will throw a bad_cast exception? How do I know?

    Observation: An incorrect dynamic_cast on pointers returns NULL instead of throwing bad_cast.

  • (author) in reply to Steve_The_Cynic

    According to S5.iii it can indeed throw a bad cast.

  • (nodebb) in reply to Remy Porter

    According to S5.iii it can indeed throw a bad cast.

    You need to read that section more carefully. Specifically section 5.b.iii (there is no section 5.iii), which covers the error case.

    iii) Otherwise, the runtime check fails.

    . If target-type is a pointer type, the result is the null pointer value of target-type. <<== Read this line.

    . If target-type is a reference type, an exception of a type that would match a handler of type std::bad_cast is thrown.

    Addendum 2026-02-02 09:22: Above all, please note the case where the input and output are pointers.

  • (nodebb)

    This seems like someone had implemented OO in C, then migrated it to C++.

  • (nodebb)

    There are various reasons for not posting a reply, but the best one is that you have nothing to say because the WTF is too horrible to contemplate.

  • (nodebb)

    Somewhere there is an unused virtual function table quietly weeping.

  • Me (unregistered)

    To me this looks more like a badly executed reinvention of tagged unions.

Leave a comment on “Wages of Inheritance”

Log In or post as a guest

Replying to comment #690831:

« Return to Article