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 

Defect Report: Clarification on casting between incomplete c

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





PostPosted: Thu May 19, 2005 3:10 pm    Post subject: Defect Report: Clarification on casting between incomplete c Reply with quote




[ Note: Forwarded to C++ Committee. -sdc ]

5.4/6 - The operand of a cast using the cast notation can be an rvalue
of type "pointer to incomplete class type". The destination type of a
cast using the cast notation can be "pointer to incomplete class type".
In such cases, even if there is a inheritance relationship between the
source and destination classes, whether the static_cast or
reinterpret_cast interpretation is used is unspecified.

The wording seems to allow the following:

1. casting to from void pointer to incomplete type

struct A;
struct B;

void *v;
A *a = (A*)v; // allowed to choose reinterpret_cast

2. variant application of static or reinterpret casting

B *b = (B*)a; // compiler can choose static_cast here
A *aa = (A*)b; // compiler can choose reinterpret_cast here
assert(aa == a); // might not hold

3. ability to somehow choose static_cast

It's not entirely clear how a compiler can choose static_cast as 5.4/6
seems to allow. I believe the intent of 5.4/6 is to force the use of
reinterpret_cast when either are incomplete class types and static_cast
iff the compiler knows both types and there is a non-ambiguous
hierarchy-traversal between that cast (or maybe not, core issue 242
talks about this). I cannot see any other interpretation because it
isn't intuitive, every compiler I've tried agrees with me, and neither
standard pointer conversions (4.10/3) nor static_cast (5.2.9/5) talk
about incomplete class types. If the committee agrees with me, I would
like to see 4.10/3 and 5.2.9/5 explicitly disallow incomplete class
types and the wording of 5.4/6 changed to not allow any other
interpretation.


[ 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.