I know typed pointers can be implicitly cast to void* when passed to a function expecting a void* argument, but I didn't expect to see it in the ternary op (at least I think that's what's going on).
Consider this simplified code:
int * dude() {
float * f = NULL;
int * i = NULL;
return (0 ? f : i); // pointer type mismatch in conditional expression (good: this is what I want)
}
But if I cast i to void*:
int * dude() {
float * f = NULL;
int * i = NULL;
return (0 ? f : (void*)i); // no error! it suddenly likes f? or is f being optimized out?
}
I'll go one step further and intentionally return f:
int * dude() {
float * f = NULL;
int * i = NULL;
return (1 ? f : (void*)i); // again no error... is f being converted to void*?
}
I expected an error in both the 2nd & 3rd examples, but I don't get one. Can someone explain what is going on here? Thanks!