-pedantic problem.
Todd Dukes
tjdukes@flash.net
Wed Nov 18 17:05:00 GMT 1998
The GTK-- toolkit currently require compiling with
pedantic. I have found what I believe to be a case
where it is too picky.
version
Reading specs from
/home/tdukes/devel/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.91.57/specs
gcc version egcs-2.91.57 19980901 (egcs-1.1 release)
Commentary on Test file
This file doesn't actually do anything except illustrate the problem.
There are two methods in Client. The method named 'broken' cause the
following message:
constTest.C: In method `int Client::broken()':
constTest.C:28: no matching function for call to `Server::request (char
*[3])'
constTest.C:7: candidates are: Server::request(const char **) <near
match>
constTest.C:29: warning: control reaches end of non-void function
`Client::broken()'
I believe this should be a valid call. The call works if you replace
return server->request(text);
with
return server->request( const_cast<const char **>(text));
Should you ever have to use const_cast to add a const?
Am I mis-understanding something, or is this a bug.
thanks,
Todd
The test program
/*
to compile
g++ -pedantic -c constTest.C
*/
class Server {
public:
int request(const char* text[]);
};
class Client {
public:
Client() {}
int method();
int broken();
private:
Server * server;
};
int Client::method() {
const char *text[3];
return server->request(text);
}
int Client::broken() {
char *text[3]; /* this should not have to be const to passed to
Server::request
*/
return server->request(text);
}
/* end test program */
--
-----------------------------------------
Todd & Lisa Dukes
tjdukes@flash.net
More information about the Gcc-bugs
mailing list