Why use 'function address == NULL' instead of 'false'?
c, c++, deobfuscation
Solution
Semantically both functions are the same: they always return false*. Folding the first expression to a constant value "false" is completely allowed by the standard since it would not change any observable side-effects (of which there are none). Since the compiler sees the entire function it also free to optimize away any calls to it and replace it with a constant "false" value.
That is, there is no "general" value in the first form and is likely a mistake on the part of the programmer. The only possibility is that it exploits some special behaviour (or defect) in a specific compiler/version. To what end I don't know however. If you wish to prevent inlining using a compiler-specific attribute would be the correct approach -- anything else is prone to breaking should the compiler change.
(*This assumes that `NULL` is never defined to be `EmptyFunc`, which would result in `true` being returned.).
Problem
Browsing among some legacy code I've found such function: ``` static inline bool EmptyFunc() { return (void*) EmptyFunc == NULL; } ``` What are the differences from this one: ``` static inline bool EmptyFunc() { return false; } ``` This code was created to compile under several different platforms, like PS2, Wii, PC... Are there any reason to use the first function? Like better optimization or avoiding some strange compiler misbehavior?