20Fermer22
squalylLe 23/07/2012 à 10:51
$ cat t.cc
  struct a {
    virtual int bar();
  };
  
  struct foo : public virtual a {
  };
  
  void test(foo *P) {
    return P->bar() + *P;
  }
  $ gcc-4.2 t.cc
  t.cc: In function 'void test(foo*)':
  t.cc:9: error: no match for 'operator+' in '(((a*)P) + (*(long int*)(P->foo::<anonymous>.a::_vptr$a + -0x00000000000000020)))->a::bar() + * P'
  t.cc:9: error: return-statement with a value, in function returning 'void'
  $ clang t.cc
  t.cc:9:18: error: invalid operands to binary expression ('int' and 'foo')
    return P->bar() + *P;
           ~~~~~~~~ ^ ~~
rahtrilove