Hacker News new | ask | show | jobs
by Ogre 5235 days ago
I can't recall the exact details, but just days or maybe a week before gold master of one title I worked on, there was a case where an object's virtual table was getting munged somehow. I do remember I managed to figure out exactly what was happening. But the amount and type of work it would take to fix would have likely delayed shipping.

So I wrote some code that constructed a new object of the same type on the stack, then

  memcpy(&realObject, &stackObject, 
         (char * )&stackObject.m_firstDataMember - (char * )&stackObject));
It worked. I'm not proud of it, but I am amused by it. I'm sure it wasn't guaranteed to work by any standard, but in practice worked fine for us.