* problem in compiling Bench++ analysis program
@ 1998-10-21 23:18 Brad Lucier
1998-10-22 18:00 ` Joe Buck
0 siblings, 1 reply; 2+ messages in thread
From: Brad Lucier @ 1998-10-21 23:18 UTC (permalink / raw)
To: joseph.orost; +Cc: egcs, lucier
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: problem in compiling Bench++ analysis program
1998-10-21 23:18 problem in compiling Bench++ analysis program Brad Lucier
@ 1998-10-22 18:00 ` Joe Buck
0 siblings, 0 replies; 2+ messages in thread
From: Joe Buck @ 1998-10-22 18:00 UTC (permalink / raw)
To: Brad Lucier; +Cc: joseph.orost, egcs, lucier
> When compiling the program a000096.cpp with the 19981019 snapshot
> of egcs, I get the following errors:
That's because Bench++ has invalid C++ code (invalid thanks to recent
changes). Literal strings are now of type const char*. This is also
likely to break many Tcl programs, thanks to Tcl's annoying lack of
const correctness.
> char *host(void) {
> return h ? h : ""; // problem here
> }
> char *compiler(void) {
> return c ? c : ""; // here
> }
> char *options(void) {
> return o ? o : ""; // and here
> }
You could write
return o ? o : (char*)"";
to fix the problem. It appears that the author of Bench++ was using it
mainly to compare Sun C++ with g++ 2.7.2.x and never tested it with a
more rigorous compiler.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1998-10-22 18:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-10-21 23:18 problem in compiling Bench++ analysis program Brad Lucier
1998-10-22 18:00 ` Joe Buck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).