[exception] [shared_ptr] ADL problem with msvc 10

AMDG I just tried to compile the following #include <boost/exception_ptr.hpp> void f() {} msvc 10 complains, 1>c:\boost\trunk\boost\smart_ptr\detail\sp_convertible.hpp(48): error C2660: 'f' : function does not take 1 arguments 1> c:\boost\trunk\boost\smart_ptr\detail\sp_convertible.hpp(66) : see reference to class template instantiation 'boost::detail::sp_convertible<Y,T>' being compiled 1> with 1> [ 1> Y=error_info_tag_t, 1> T=boost::exception_detail::error_info_base 1> ] 1> c:\boost\trunk\boost\exception\info.hpp(171) : see reference to class template instantiation 'boost::detail::sp_enable_if_convertible<Y,T>' being compiled 1> with 1> [ 1> Y=error_info_tag_t, 1> T=boost::exception_detail::error_info_base 1> ] 1> c:\boost\trunk\boost\exception\info.hpp(188) : see reference to function template instantiation 'const E &boost::exception_detail::set_info<E,boost::tag_original_exception_type,const type_info*>(const E &,const boost::error_info<Tag,T> &)' being compiled 1> with 1> [ 1> E=boost::unknown_exception, 1> Tag=boost::tag_original_exception_type, 1> T=const type_info * 1> ] 1> c:\boost\trunk\boost\exception\detail\exception_ptr.hpp(132) : see reference to function template instantiation 'const boost::unknown_exception &boost::operator <<<boost::unknown_exception,boost::tag_original_exception_type,const type_info*>(const E &,const boost::error_info<Tag,T> &)' being compiled 1> with 1> [ 1> E=boost::unknown_exception, 1> Tag=boost::tag_original_exception_type, 1> T=const type_info * 1> ] 1> c:\boost\trunk\boost\exception\detail\exception_ptr.hpp(111) : see reference to function template instantiation 'void boost::unknown_exception::add_original_type<std::exception>(const E &)' being compiled 1> with 1> [ 1> E=std::exception 1> ] This appears to be because type_info is defined in the global namespace, so ADL for boost::error_info<boost::tag_original_exception_type, const type_info *> picks up the global f. I don't have a fix for this yet. In Christ, Steven Watanabe

Steven Watanabe wrote:
AMDG
I just tried to compile the following
#include <boost/exception_ptr.hpp> void f() {}
msvc 10 complains, 1>c:\boost\trunk\boost\smart_ptr\detail\sp_convertible.hpp(48): error C2660: 'f' : function does not take 1 arguments ... This appears to be because type_info is defined in the global namespace, so ADL for boost::error_info<boost::tag_original_exception_type, const type_info *> picks up the global f. I don't have a fix for this yet.
You mean apart from renaming f to something like _spc_helper_f? :-) Lookup from within a class scope shouldn't activate ADL when it finds a member, so it seems to me that MSVC 10 is wrong here, but I don't have chapter and verse handy, so who knows.

AMDG Peter Dimov wrote:
Steven Watanabe wrote:
I just tried to compile the following
#include <boost/exception_ptr.hpp> void f() {}
msvc 10 complains, 1>c:\boost\trunk\boost\smart_ptr\detail\sp_convertible.hpp(48): error C2660: 'f' : function does not take 1 arguments ... This appears to be because type_info is defined in the global namespace, so ADL for boost::error_info<boost::tag_original_exception_type, const type_info *> picks up the global f. I don't have a fix for this yet.
You mean apart from renaming f to something like _spc_helper_f? :-)
Lookup from within a class scope shouldn't activate ADL when it finds a member, so it seems to me that MSVC 10 is wrong here, but I don't have chapter and verse handy, so who knows.
I think that the compiler is correct to find the global f, but I don't think it should cause the static f to be hidden. 3.4.2 "When an unqualified name is used as the postfix-expression in a function call..." 5.2.2 "There are two kinds of function call: ordinary function call and member function57) (9.3) call." footnote 57 "A static member function (9.4) is an ordinary function." Anyway, the attached patch fixes this problem (and http://svn.boost.org/trac/boost/ticket/4108) and should be harmless for other compilers. In Christ, Steven Watanabe

Steven Watanabe:
I think that the compiler is correct to find the global f, but I don't think it should cause the static f to be hidden.
3.4.2 "When an unqualified name is used as the postfix-expression in a function call..."
Look further in 3.4.2/3: Let X be the lookup set produced by unqualified lookup (3.4.1) and let Y be the lookup set produced by argument dependent lookup (defined as follows). If X contains - a declaration of a class member, or - a block-scope function declaration that is not a using-declaration, or - a declaration that is neither a function or a function template then Y is empty. X contains f, a class member, even if it's a static class member.
- enum _vt { value = sizeof( f( static_cast<Y*>(0) ) ) == sizeof(yes) }; + enum _vt { value = sizeof( (f)( static_cast<Y*>(0) ) ) == sizeof(yes) };
Yes, this works. No objections.

On Sat, Apr 17, 2010 at 3:42 PM, Peter Dimov <pdimov@pdimov.com> wrote:
Steven Watanabe:
I think that the compiler is correct to find the global f, but I don't think it should cause the static f to be hidden.
3.4.2 "When an unqualified name is used as the postfix-expression in a function call..."
Look further in 3.4.2/3:
Let X be the lookup set produced by unqualified lookup (3.4.1) and let Y be the lookup set produced by argument dependent lookup (defined as follows). If X contains - a declaration of a class member, or - a block-scope function declaration that is not a using-declaration, or - a declaration that is neither a function or a function template then Y is empty.
X contains f, a class member, even if it's a static class member.
- enum _vt { value = sizeof( f( static_cast<Y*>(0) ) ) == sizeof(yes) }; + enum _vt { value = sizeof( (f)( static_cast<Y*>(0) ) ) == sizeof(yes) };
Yes, this works. No objections.
Is this a request for Steven to apply the patch:-? --Beman

AMDG Beman Dawes wrote:
On Sat, Apr 17, 2010 at 3:42 PM, Peter Dimov <pdimov@pdimov.com> wrote:
Steven Watanabe:
- enum _vt { value = sizeof( f( static_cast<Y*>(0) ) ) == sizeof(yes) }; + enum _vt { value = sizeof( (f)( static_cast<Y*>(0) ) ) == sizeof(yes) };
Yes, this works. No objections.
Is this a request for Steven to apply the patch:-?
I already applied it to the trunk. It clears a couple of failures for msvc 10, and it looks like it didn't break anything else. In Christ, Steven Watanabe
participants (3)
-
Beman Dawes
-
Peter Dimov
-
Steven Watanabe