Topic: Clarification needed for code in 3.4.1[3]
Author: sgganesh@gmail.com (Ganesh)
Date: Mon, 27 Sep 2004 16:56:06 GMT Raw View
3.4.1[3] reads:
The lookup for an unqualified name used as the postfix-expression of a
function call is described in 3.4.2.
[Note: for purposes of determining (during parsing) whether an
expression is a postfix-expression for a function call, the usual name
lookup rules apply. The rules in 3.4.2 have no effect on the syntactic
interpre-tation of an expression. For example,
typedef int f;
struct A {
friend void f(A &);
operator int();
void g(A a) {
f(a);
}
};
The expression f(a) is a cast-expression equivalent to int(a). Because
the expression is not a function call, the argument-dependent name
lookup (3.4.2) does not apply and the friend function f is not found.
]
The code doesn't compile in any of the compilers I tested (VC++ 7.1,
Comeau online compiler, gcc 3.2, aCC 5.55). Is it the intent of the
code just to explain how the expression should be syntactically
interpreted? In that case, shouldn't it be explicitly stated to avoid
misinterpretation?
When struct A is put inside a namespace to workaround this problem (as
modena conformance testcase c0341031 does), these compilers give wrong
results - they call function f instead of treating f(a) as cast
expression. Can I safely conclude that they don't conform?
-Ganesh
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]