This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/49152] Unhelpful diagnostic for iterator dereference


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49152

--- Comment #23 from Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> 2012-03-31 00:34:58 UTC ---
BTW, I think this example was mentioned some where already, but I cannot find
it now. From http://clang.llvm.org/diagnostics.html

manuel@gcc12:~$ cat t.cc
struct a {
  virtual int bar();
};

struct foo : public virtual a {
};

int test(foo *P) {
  return P->bar() + *P;
}

manuel@gcc12:~$ trunk/180166/install/bin/g++ -fsyntax-only ~/t.cc
/home/manuel/t.cc: In function âvoid test(foo*)â:
/home/manuel/t.cc:9:22: error: no match for âoperator+â in â(((a*)P) +
((sizetype)(*(long int*)(P->foo::<anonymous>.a::_vptr.a +
0xffffffffffffffffffffffffffffffe0u))))->a::bar() + * Pâ

manuel@gcc12:~$ ~/bin/clang -fsyntax-only ~/t.cc 
/home/manuel/t.cc:9:19: error: invalid operands to binary expression ('int' and
'foo')
  return P->bar() + *P;
         ~~~~~~~~ ^ ~~
1 error generated.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]