C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Clarification needed for code in 3.4.1[3]

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards
View previous topic :: View next topic  
Author Message
Ganesh
Guest





PostPosted: Mon Sep 27, 2004 4:56 pm    Post subject: Clarification needed for code in 3.4.1[3] Reply with quote



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 ]

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.