Quote:Original post by Red Ant
By the way, why does C++ even care if the pointer arguments have the same const-qualifiers in both function signatures? I mean they're just local variables ... what's it to C++ if the function changes the value of a local variable. I can understand that equal constness matters with regard to the pointee, but why the pointers themselves? Hmm.
The existence of const function arguments is a great demonstration of the silliness inherent in the C++ const model. Nevertheless, it really does make sense to disallow coercion of this sort, because constness can certainly play into calling conventions. For instance, a particular hypothetical compiler on a hypothetical architecture might decide to pass const arguments through registers that were slower to write than others. (I know, that's a bit contrived.) A function pointer would then have to keep around not only the address to jump to, but information on which arguments need to be passed in different registers. It's the same reason why function pointers don't support argument-type contravariance or return-type covariance.