In the following code, the functions test() and foo() are both declared with a flags parameter which is marked const. The declaration of the actual functions (blah::foo() and blah::test() below the class declaration) do not specify the const modifier and yet the compiler does not complain. This happens with any number of parameters in the function declarations. It does not happen with complex types (other classes) only basic types like int. Since I may want to overload such functions, it is a problem. ("int" and "int const" are not supposed to be the same type.) class blah { public: blah() {} void test(int const flags); private: bool foo(int const flags); int f_test; }; bool blah::foo(int flags) { if(flags & 0x10) { f_test = 3; } else { f_test = 1; } return (flags & 0x03) != 0; } void blah::test(int flags) { flags |= 0x80; foo(flags | 0x10); } int main() { blah a; a.test(3); return 0; }
Yes, that's how C++ works. Top-level const qualifiers are not part of a function signature. This is not a bug, definitely not one with "major" severity!
http://www.dansaks.com/articles/2000-02%20Top-Level%20cv-Qualifiers%20in%20Function%20Parameters.pdf
Wow! I see that is now... "normal behavior". If you ask me, it sucks. But well... I suppose I don't count. Thank you for the PDF reference.