This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Q.: inconsistent (?) warnings about functions called through non-compatible types


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]