4 ms·
And again, my favorite accidental usages of undefined behaviour in C++ are optimised into BS. (1) if (this == NULL): this is super useful in non-virtual functi
by beeforpork 10y ago
And again, my favorite accidental usages of undefined behaviour in C++ are optimised into BS.
(1) if (this == NULL): this is super useful in non-virtual functions, because NULL is the object that subclasses all classes, so the only universal error object.
(2) memset in operator new: in C++03, we did not have initialisers inside struct{}, so quicky zero the obj to avoid error-prone manual inits of all embedded ints.
This is really becoming ridiculous. Having a notion of how C/C++ corresponds to what the machine will do seems to be more and more regarded as evil.
- deleted 10y ago[deleted]
- Matheus28 10y agoExcept `if(this == nullptr)` doesn't always work: https://blogs.msdn.microsoft.com/oldnewthing/20160224-00/?p=93081 https://blogs.msdn.microsoft.com/oldnewthing/20160224-00/?p=... You might get a pointer to NULL+8 or something like that if the class inherents from more than one class. Maybe you should just write compliant code after all.