This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
problem in compiling Bench++ analysis program
- To: joseph dot orost at att dot com
- Subject: problem in compiling Bench++ analysis program
- From: Brad Lucier <lucier at math dot purdue dot edu>
- Date: Wed, 21 Oct 1998 16:17:58 -0500 (EST)
- Cc: egcs at cygnus dot com, lucier at math dot purdue dot edu
When compiling the program a000096.cpp with the 19981019 snapshot
of egcs, I get the following errors:
peano-53% make a000096
/opt/egcs-19981019/bin/g++ -o a000096 a000096.cpp ; \
E=$?; if [ $E -ne 0 ]; then echo a000096: error >>bench++.err; fi; exit $E
a000096.cpp: In method `char * test_keeper::host()':
a000096.cpp:88: return to `char *' from `const char *' discards const
a000096.cpp: In method `char * test_keeper::compiler()':
a000096.cpp:91: return to `char *' from `const char *' discards const
a000096.cpp: In method `char * test_keeper::options()':
a000096.cpp:94: return to `char *' from `const char *' discards const
make: *** [a000096] Error 1
The offending code is
class test_keeper {
public:
friend class test_keeper_iterator;
test_keeper() { // constructor
head = tail = (test_keeper_impl *)0;
h = (char *)0;
}
void insert_host(char *host) {
h = new char[strlen(host)+1];
strcpy(h, host);
}
void insert_compiler(char *compiler) {
c = new char[strlen(compiler)+1];
strcpy(c, compiler);
}
void insert_options(char *options) {
o = new char[strlen(options)+1];
strcpy(o, options);
}
void insert(test_description d) {
test_keeper_impl *i = new test_keeper_impl;
i->next = (test_keeper_impl *) 0;
i->desc.test_name = new char[strlen(d.test_name)+1];
strcpy(i->desc.test_name, d.test_name);
i->desc.seconds = d.seconds;
if(tail) {
tail->next = i;
tail = i;
} else {
head = tail = i;
}
}
char *host(void) {
return h ? h : ""; // problem here
}
char *compiler(void) {
return c ? c : ""; // here
}
char *options(void) {
return o ? o : ""; // and here
}
double lookup(char *test_name) {
for(test_keeper_impl *i = head; i; i = i->next) {
if(strcasecmp(test_name, i->desc.test_name) == 0) {
return i->desc.seconds;
}
}
return -1.0;
}
private:
class test_keeper_impl {
public:
test_keeper_impl *next;
test_description desc;
} *head, *tail;
char *h, *c, *o;
};
This compiled fine with egcs-1.0.3a.
I don't know whether the code is right or whether the compiler is right,
I'm just passing this on to you.
Brad Lucier lucier@math.purdue.edu