Invalid method signatures are generated where parameter types are defined, particularly inside namespaces (namespace, struct, class).
Created attachment 6366 [details] Test case. Test case reproduces the bug.
Command line: g++ gcctest.cc Compiler output: gcctest.cc: In function `int main(int, char**)': gcctest.cc:28: error: invalid conversion from `const char*' to `char*' gcctest.cc:28: error: initializing argument 1 of `void ScopeTest::test(char*) '
Here is a smaller example: typedef char* CharPtr; void t(const CharPtr); void f(const char *t1) { t(t1); } But I think this is invalid.
'const CharPtr' is a constant pointer to a character. 'const char *' is a pointer to a constant character. The testcase is therefore invalid code, and gcc is correct in reporting an error. W.
The error message from gcc, then, is misleading. It fails to indicate any const qualifier in the method signature. Should this be filed as a separate bug?
Um, why do you say that? The error message is invalid conversion from `const char*' to `char*' which is about as clear as it can be, no? W.
gcctest.cc:28: error: initializing argument 1 of `void ScopeTest::test(char*) ' Argument 1 of ScopeTest::test is "const TestTraits::CharPtr". The error message indicates a misleading error and an invalid method signature, hence the bug report. As you are technically correct about the error report, gcc should report "error: invalid conversion from `const char*' to `char const*'" and "error: initializing argument 1 of void ScopeTest::test(char const*)." While the fact of the error is correct, the report of the error generated by gcc is incorrect and misleading.
No, gcc is still correct since from a language viewpoint, the following two declarations are exactly identical: void f(char *); void f(char *const); For the argument signature, the const in the second case is irrelevant, and is thus dropped. You can see this by simply compiling these two lines above (as a C file; remember that C does not have function overloading) -- the compiler accepts this as a duplicate declaration, whereas it does not accept these two lines: void f(char *); void f(const char*); generating an error about conflicting declarations. W.
Right you are. I re-read ISO/IEC 14882:1998(E)-8.3.5(3). Thanks for your time and the discussion.