2 ms·
It also relies on implementation-specific behavior in the compiler, since the latter is not actually required to follow established the convention for argument
by int_19h 10y ago
It also relies on implementation-specific behavior in the compiler, since the latter is not actually required to follow established the convention for argument passing, so long as it can prove that the only place the function is called from is the same translation unit.
In fact, so far as I can tell by looking at the first example, the compiler can circumvent this whole thing by noting that:
1. DoubleToTheInt is only ever called in the same unit, so it can be inlined - no need to generate the function.
2. Pointer to DoubleToTheInt is created, but is then immediately cast to an incompatible function type, which is undefined behavior - and so it can be substituted with any random value, say, whatever happens to be in EAX at that moment (any U.B. is substitutable for any other U.B.!), and the compiler can still avoid generating the actual function.