This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/49152] Unhelpful diagnostic for iterator dereference
- From: "manu at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 31 Mar 2012 00:34:58 +0000
- Subject: [Bug c++/49152] Unhelpful diagnostic for iterator dereference
- Auto-submitted: auto-generated
- References: <bug-49152-4@http.gcc.gnu.org/bugzilla/>
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.