17821 – [3.4/4.0 Regression] Poor diagnostic for using . instead of -> (original) (raw)
Description Ivan Godard 2004-10-04 00:25:11 UTC
struct A { A(int i) {} }; struct B { int i; }; struct C { B* p; }; int main() { C c; A(c.p->i); A(c.p.i); return 0; }
gets you:
~/ootbc/members/src$ c++ foo.cc
foo.cc: In function int main()': foo.cc:13: error: expected primary-expression before '(' token foo.cc:13: error: i' has not been declared
foo.cc:13: error: request for member of non-aggregate type before ')' token
when the actual problem is a wrong dereference level ("." instead of "->")
Comment 1 Drea Pinski 2004-10-04 00:30:29 UTC
A related testcase works correctly (if we change A to a function instead): void A(int); struct B { int i; }; struct C { struct B* p; }; int main() { struct C c; A(c.p->i); A(c.p.i); return 0; }
pr17821.c:11: error: request for member i' in non-class type B*'
Comment 2 Drea Pinski 2004-10-04 00:31:37 UTC
Plus this is a regression:
3.3 gives:
pr17821.cc:13: error: request for member i' in c.C::p', which is of non-class
Comment 5 Mark Mitchell 2004-10-10 05:35:59 UTC
Fixed in GCC 3.4.3.