signature S / ... S::f(...) const doesn't work !
Christophe Avoinne
hlide@club-internet.fr
Sat Oct 9 15:15:00 GMT 1999
When trying to keep `const' after S::value(), i cannot compile this example
:
ÃÂ #include "iostream"
ÃÂ
ÃÂ signature S
ÃÂ {
ÃÂ ÃÂ ÃÂ int value() const;
ÃÂ };
ÃÂ
ÃÂ class C
ÃÂ {
ÃÂ ÃÂ ÃÂ int i;
ÃÂ public:
ÃÂ ÃÂ ÃÂ C(int i = 0) : i(i) {}
ÃÂ ÃÂ ÃÂ int value() const
ÃÂ ÃÂ ÃÂ {
ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ return i;
ÃÂ ÃÂ ÃÂ }
ÃÂ ÃÂ ÃÂ int dummy()
ÃÂ ÃÂ ÃÂ {
ÃÂ ÃÂ ÃÂ }
ÃÂ };
ÃÂ int main()
ÃÂ {
ÃÂ ÃÂ ÃÂ S *s = new C(10);
ÃÂ ÃÂ ÃÂ cout
ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ << s->value() // <--- line
22 !
ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ << endl
ÃÂ ÃÂ ÃÂ ;
ÃÂ ÃÂ ÃÂ return 0;
ÃÂ }
here is what I obtain :
essai.cc: In function `int main()':
essai.cc:22: Internal compiler error.
essai.cc:22: Please submit a full bug report.
essai.cc:22: See <URL: http://egcs.cygnus.com/faq.html#bugreport >
for instructions.
methinks using `const' after S::value() could not be a misuse, because
if a pointer of "const class C" can only call "C::value() const" and a
pointer of "class C" can both call "C::value() const" and "C::dummy()",
so a pointer of "signature S" should also be both able to call "C::value()
const" and "C::dummy()" !
ÃÂ
More information about the Gcc-bugs
mailing list