<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Apr 25, 2013 at 1:01 AM, Handa, Ramneek <span dir="ltr"><<a href="mailto:Ramneek.Handa@sc.com" target="_blank">Ramneek.Handa@sc.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I am confused on how to find this in the std document.<br>
What I find in there is (from n3485):<br>
1. Page-231, clause 4 - Access control is applied uniformly to all<br>
names, whether the names are referred to from declarations or<br>
expressions.<br>
2. Page-231, clause 5 - It should be noted that it is access to members<br>
and base classes that is controlled, not their visibility. Names<br>
of members are still visible, and implicit conversions to base classes<br>
are still considered, when those members<br>
and base classes are inaccessible. The interpretation of a given<br>
construct is established without regard to<br>
access control. If the interpretation established makes use of<br>
inaccessible member names or base classes, the<br>
construct is ill-formed.<br>
<br>
I am not sure what they mean by visibility?<br>
<br>
Could you send me what sections and clauses are you referring to?<br></blockquote><div><br></div><div style>We're not a C++ support forum; your question might be better directed to stackoverflow. If you want to understand how the C++11 rules differ from C++03, you should compare the C++11 and C++03 standards. Search for things like "would be ill-formed" and "type deduction fails".</div>
<div style><br></div><div style>If you think that Clang is actually wrong here (if this code is still rejected with -std=c++11, for instance), please provide preprocessed (and preferably reduced) source code.</div><div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thanks for response again.<br>
<br>
Regards.<br>
<div><div class="h5"><br>
<br>
-----Original Message-----<br>
From: <a href="mailto:cfe-dev-bounces@cs.uiuc.edu">cfe-dev-bounces@cs.uiuc.edu</a> [mailto:<a href="mailto:cfe-dev-bounces@cs.uiuc.edu">cfe-dev-bounces@cs.uiuc.edu</a>]<br>
On Behalf Of John McCall<br>
Sent: Thursday, April 25, 2013 2:27 PM<br>
To: Ramneek Handa<br>
Cc: clang-dev Developers<br>
Subject: Re: [cfe-dev] private class members access fails with<br>
meta-programming in clang?<br>
<br>
On Apr 24, 2013, at 9:20 AM, Ramneek Handa <<a href="mailto:ramneekhanda@gmail.com">ramneekhanda@gmail.com</a>><br>
wrote:<br>
> I thought this should pass with clang.<br>
><br>
> x-- start --x<br>
><br>
> #include <boost/mpl/has_xxx.hpp><br>
><br>
> BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(hasSomething, Data, false);<br>
><br>
> class A {<br>
> private:<br>
> struct Data {<br>
> };<br>
> };<br>
><br>
><br>
> void function(bool val = hasSomething<A>::value) {}<br>
><br>
><br>
> x-- end --x<br>
><br>
> however it produces following output:<br>
> test_private_data.cpp:3:49: error: 'Data' is a private member of 'A'<br>
> BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(hasSomething, Data, false);<br>
> ^<br>
> /usr/include/boost/mpl/has_xxx.hpp:195:68: note: expanded from macro<br>
'BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF'<br>
> , boost::mpl::aux::type_wrapper<BOOST_MSVC_TYPENAME U::name>* = 0 \<br>
> ^<br>
> test_private_data.cpp:3:1: note: while substituting deduced template<br>
arguments into function template 'test' [with U = A]<br>
> BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(hasSomething, Data, false);<br>
> ^<br>
> /usr/include/boost/mpl/has_xxx.hpp:193:41: note: expanded from macro<br>
'BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF'<br>
> static boost::mpl::aux::yes_tag test( \<br>
> ^<br>
> test_private_data.cpp:12:26: note: in instantiation of template class<br>
'hasSomething<A, mpl_::bool_<false> >' requested here<br>
> void function(bool val = hasSomething<A>::value) {}<br>
> ^<br>
> 1 error generated.<br>
> /usr/bin/ld: /tmp/test_private_data-Hatffv.o: No such file: No such<br>
file or directory<br>
> clang: error: linker command failed with exit code 1 (use -v to see<br>
invocation)<br>
><br>
><br>
><br>
><br>
> BUT it passes with GCC.<br>
><br>
> Which one is right?<br>
<br>
I assume that Boost is using SFINAE here in its check.  Access control<br>
violations were not subject to SFINAE prior to C++11, and Clang is<br>
correct<br>
to diagnose it.  You can compile with -std=c++11 to make this work;  the<br>
trait will return 'false'.<br>
<br>
John.<br>
<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br>
</div></div>This email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please delete all copies and notify the sender immediately. You may wish to refer to the incorporation details of Standard Chartered PLC, Standard Chartered Bank and their subsidiaries at <a href="http://www.standardchartered.com/en/incorporation-details.html" target="_blank">http://www.standardchartered.com/en/incorporation-details.html</a>.<br>

<div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</div></div></blockquote></div><br></div></div>