On 29 March 2015 at 19:32, Godmar Back wrote:
> Why does assigning boolFunctionThatReturnsFalse to a variable f after
> the cast, instead of directly dereferencing it, silence the compiler's
> warnings?

Because the cast itself is OK, and the call that results in undefined
behaviour is separate from the cast. The compiler is not smart enough
to see that in the call f() the value of f is not really an
intFunction.

In the second case the compiler knows for a fact that the function
being called does not have the correct type, because the cast and the
call are part of the same expression.

Reply via email to