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