Oddbean new post about | logout
 oh wow this works, prob compiler optimisation but it's still some dangerous syntax

https://cdn.masto.host/mastodongamedevplace/media_attachments/files/111/133/272/856/181/467/original/a3071592d8bf52c5.png

https://cdn.masto.host/mastodongamedevplace/media_attachments/files/111/133/276/330/272/333/original/5f601d632eada3df.png 
 @eb948c00 Well, technically this is lecit as the `this `pointer is not relevant being `nullptr`.

If we assume that the call `ptr->someFunction()`is ideally expanded as `MyScaryClass::someFunction(ptr)` as the vtable is not accessed.

However, any decent compiler (with the relevant warnings enabled) should warn this is not the best way to write this piece of code. 
 @eb948c00 yeeeah. I would be surprised if whoever wrote that understood what they were doing.
Really that code is just doing...

MyScaryClass::someFunction()

static class functions are exactly like "regular" C style functions - there's no hidden / implicit this pointer passed to it.

afiak the whole null pointer bit basically does nothing other than scope the (static) function to class so the compiler can resolve it - honestly, I'm surprised it complies though!