[Boost-bugs] [Boost C++ Libraries] #12895: VS 2012: zip_iterator dereference causes a compiler error

Subject: [Boost-bugs] [Boost C++ Libraries] #12895: VS 2012: zip_iterator dereference causes a compiler error
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-03-10 21:26:44


#12895: VS 2012: zip_iterator dereference causes a compiler error
-------------------------------+------------------------------
 Reporter: daniel.kruegler@… | Owner: jeffrey.hellrung
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: iterator
  Version: Boost 1.63.0 | Severity: Problem
 Keywords: |
-------------------------------+------------------------------
 Using Visual Studio 2012 (vc110), any direct or indirect usage of the
 dereference operation of zip_iterator produces now a compiler error, a
 simple reproducer is the following example:

 {{{
 #include "boost/iterator/zip_iterator.hpp"

 int main()
 {
     typedef boost::tuple<char*, char*> iterators_t;
     char chars[] = "abc";
     iterators_t iters(chars + 0, chars + 3);
     boost::iterators::zip_iterator<iterators_t> zip(iters);
     *zip;
 }
 }}}

 which results in the following compiler output:

 {{{
 1>c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(364): error C2825: '_Iter': must be a class or
 namespace when followed by '::'
 1>
 c:\projects\thirdparty\boost_1_63_0\boost\iterator\iterator_traits.hpp(28)
 : see reference to class template instantiation
 'std::iterator_traits<_Iter>' being compiled
 1> with
 1> [
 1> _Iter=char *const
 1> ]
 1>
 c:\projects\thirdparty\boost_1_63_0\boost\iterator\zip_iterator.hpp(90) :
 see reference to class template instantiation
 'boost::iterators::iterator_reference<Iterator>' being compiled
 1> with
 1> [
 1> Iterator=char *const
 1> ]
 1>
 c:\projects\thirdparty\boost_1_63_0\boost\utility\result_of.hpp(190) : see
 reference to class template instantiation
 'boost::iterators::detail::dereference_iterator::result<<unnamed-symbol>>'
 being compiled
 1> with
 1> [
 1> <unnamed-
 symbol>=boost::iterators::detail::dereference_iterator (char *const &)
 1> ]
 1>
 c:\projects\thirdparty\boost_1_63_0\boost\utility\result_of.hpp(197) : see
 reference to class template instantiation
 'boost::detail::result_of_nested_result<F,FArgs>' being compiled
 1> with
 1> [
 1> F=boost::iterators::detail::dereference_iterator,
 1> FArgs=boost::iterators::detail::dereference_iterator (char
 *const &)
 1> ]
 1>
 c:\projects\thirdparty\boost_1_63_0\boost\utility\detail\result_of_iterate.hpp(37)
 : see reference to class template instantiation
 'boost::detail::tr1_result_of_impl<F,FArgs,HasResultType>' being compiled
 1> with
 1> [
 1> F=boost::iterators::detail::dereference_iterator,
 1> FArgs=boost::iterators::detail::dereference_iterator (char
 *const &),
 1> HasResultType=false
 1> ]
 1>
 c:\projects\thirdparty\boost_1_63_0\boost\utility\detail\result_of_iterate.hpp(160)
 : see reference to class template instantiation 'boost::tr1_result_of<F>'
 being compiled
 1> with
 1> [
 1> F=boost::iterators::detail::dereference_iterator (char
 *const &)
 1> ]
 1>
 c:\projects\thirdparty\boost_1_63_0\boost\fusion\view\transform_view\detail\apply_transform_result.hpp(31)
 : see reference to class template instantiation 'boost::result_of<F>'
 being compiled
 1> with
 1> [
 1> F=boost::iterators::detail::dereference_iterator (char
 *const &)
 1> ]
 1>
 c:\projects\thirdparty\boost_1_63_0\boost\mpl\aux_\preprocessed\plain\apply_wrap.hpp(39)
 : see reference to class template instantiation
 'boost::fusion::detail::apply_transform_result<F>::apply<T0>' being
 compiled
 1> with
 1> [
 1> F=boost::iterators::detail::dereference_iterator,
 1> T0=char *const &
 1> ]
 1>
 c:\projects\thirdparty\boost_1_63_0\boost\mpl\aux_\preprocessed\plain\apply.hpp(43)
 : see reference to class template instantiation
 'boost::mpl::apply_wrap1<F,T1>' being compiled
 1> with
 1> [
 1>
 F=boost::fusion::detail::apply_transform_result<boost::iterators::detail::dereference_iterator>,
 1> T1=char *const &
 1> ]
 1>
 c:\projects\thirdparty\boost_1_63_0\boost\mpl\aux_\preprocessed\plain\apply.hpp(51)
 : see reference to class template instantiation 'boost::mpl::apply1<F,T1>'
 being compiled
 1> with
 1> [
 1>
 F=boost::fusion::detail::apply_transform_result<boost::iterators::detail::dereference_iterator>,
 1> T1=char *const &
 1> ]
 1>
 c:\projects\thirdparty\boost_1_63_0\boost\fusion\view\transform_view\detail\deref_impl.hpp(38)
 : see reference to class template instantiation 'boost::mpl::apply<F,T1>'
 being compiled
 1> with
 1> [
 1>
 F=boost::fusion::detail::apply_transform_result<boost::iterators::detail::dereference_iterator>,
 1> T1=char *const &
 1> ]
 1>
 c:\projects\thirdparty\boost_1_63_0\boost\fusion\iterator\deref.hpp(54) :
 see reference to class template instantiation
 'boost::fusion::extension::deref_impl<boost::fusion::transform_view_iterator_tag>::apply<Iterator>'
 being compiled
 1> with
 1> [
 1>
 Iterator=boost::fusion::transform_view_iterator<boost::fusion::boost_tuple_iterator<const
 iterators_t>,boost::iterators::detail::dereference_iterator>
 1> ]
 1>
 c:\projects\thirdparty\boost_1_63_0\boost\fusion\adapted\boost_tuple\detail\build_cons.hpp(53)
 : see reference to class template instantiation
 'boost::fusion::result_of::deref<Iterator>' being compiled
 1> with
 1> [
 1>
 Iterator=boost::fusion::transform_view_iterator<boost::fusion::boost_tuple_iterator<const
 iterators_t>,boost::iterators::detail::dereference_iterator>
 1> ]
 1>
 c:\projects\thirdparty\boost_1_63_0\boost\fusion\adapted\boost_tuple\detail\build_cons.hpp(52)
 : while compiling class template member function
 'boost::tuples::cons<HT,TT>
 boost::fusion::detail::build_tuple_cons<First,Last>::call(const First
 &,const Last &)'
 1> with
 1> [
 1> HT=char &,
 1> TT=boost::tuples::cons<char
 &,boost::fusion::detail::build_tuple_cons<boost::fusion::single_view_iterator<const
 boost::fusion::single_view<char
 &>,boost::mpl::int_<1>>,boost::fusion::single_view_iterator<const
 boost::fusion::single_view<char &>,boost::mpl::int_<1>>>::type>,
 1>
 First=boost::fusion::transform_view_iterator<boost::fusion::boost_tuple_iterator<const
 iterators_t>,boost::iterators::detail::dereference_iterator>,
 1>
 Last=boost::fusion::transform_view_iterator<boost::fusion::boost_tuple_iterator<const
 boost::tuples::null_type>,boost::iterators::detail::dereference_iterator>
 1> ]
 1>
 c:\projects\thirdparty\boost_1_63_0\boost\fusion\adapted\boost_tuple\detail\convert_impl.hpp(43)
 : see reference to function template instantiation
 'boost::tuples::cons<HT,TT>
 boost::fusion::detail::build_tuple_cons<First,Last>::call(const First
 &,const Last &)' being compiled
 1> with
 1> [
 1> HT=char &,
 1> TT=boost::tuples::cons<char
 &,boost::fusion::detail::build_tuple_cons<boost::fusion::single_view_iterator<const
 boost::fusion::single_view<char
 &>,boost::mpl::int_<1>>,boost::fusion::single_view_iterator<const
 boost::fusion::single_view<char &>,boost::mpl::int_<1>>>::type>,
 1>
 First=boost::fusion::transform_view_iterator<boost::fusion::boost_tuple_iterator<const
 iterators_t>,boost::iterators::detail::dereference_iterator>,
 1>
 Last=boost::fusion::transform_view_iterator<boost::fusion::boost_tuple_iterator<const
 boost::tuples::null_type>,boost::iterators::detail::dereference_iterator>
 1> ]
 1>
 c:\projects\thirdparty\boost_1_63_0\boost\fusion\adapted\boost_tuple\detail\convert_impl.hpp(37)
 : see reference to class template instantiation
 'boost::fusion::detail::build_tuple_cons<First,Last>' being compiled
 1> with
 1> [
 1>
 First=boost::fusion::transform_view_iterator<boost::fusion::boost_tuple_iterator<const
 iterators_t>,boost::iterators::detail::dereference_iterator>,
 1>
 Last=boost::fusion::transform_view_iterator<boost::fusion::boost_tuple_iterator<const
 boost::tuples::null_type>,boost::iterators::detail::dereference_iterator>
 1> ]
 1>
 c:\projects\thirdparty\boost_1_63_0\boost\fusion\sequence\convert.hpp(37)
 : see reference to class template instantiation
 'boost::fusion::extension::convert_impl<boost::fusion::boost_tuple_tag>::apply<Sequence>'
 being compiled
 1> with
 1> [
 1> Sequence=const boost::fusion::transform_view<const
 iterators_t,boost::iterators::detail::dereference_iterator>
 1> ]
 1>
 c:\projects\thirdparty\boost_1_63_0\boost\iterator\zip_iterator.hpp(214) :
 see reference to class template instantiation
 'boost::fusion::result_of::convert<Tag,Sequence>' being compiled
 1> with
 1> [
 1> Tag=tag,
 1> Sequence=const boost::fusion::transform_view<const
 iterators_t,boost::iterators::detail::dereference_iterator>
 1> ]
 1>
 c:\projects\thirdparty\boost_1_63_0\boost\iterator\zip_iterator.hpp(289) :
 see reference to function template instantiation 'reference
 boost::iterators::detail::converter<reference>::call<boost::fusion::transform_view<Sequence1,Sequence2>>(Seq)'
 being compiled
 1> with
 1> [
 1> reference=reference,
 1> Sequence1=const iterators_t,
 1> Sequence2=boost::iterators::detail::dereference_iterator,
 1> Seq=boost::fusion::transform_view<const
 iterators_t,boost::iterators::detail::dereference_iterator>
 1> ]
 1>
 c:\projects\thirdparty\boost_1_63_0\boost\iterator\zip_iterator.hpp(289) :
 see reference to function template instantiation 'reference
 boost::iterators::detail::converter<reference>::call<boost::fusion::transform_view<Sequence1,Sequence2>>(Seq)'
 being compiled
 1> with
 1> [
 1> reference=reference,
 1> Sequence1=const iterators_t,
 1> Sequence2=boost::iterators::detail::dereference_iterator,
 1> Seq=boost::fusion::transform_view<const
 iterators_t,boost::iterators::detail::dereference_iterator>
 1> ]
 1>
 c:\projects\thirdparty\boost_1_63_0\boost\iterator\zip_iterator.hpp(284) :
 while compiling class template member function 'boost::tuples::cons<HT,TT>
 boost::iterators::zip_iterator<IteratorTuple>::dereference(void) const'
 1> with
 1> [
 1> HT=char &,
 1> TT=boost::tuples::cons<char
 &,boost::fusion::detail::build_tuple_cons<boost::fusion::single_view_iterator<const
 boost::fusion::single_view<char
 &>,boost::mpl::int_<1>>,boost::fusion::single_view_iterator<const
 boost::fusion::single_view<char &>,boost::mpl::int_<1>>>::type>,
 1> IteratorTuple=iterators_t
 1> ]
 1>
 c:\projects\thirdparty\boost_1_63_0\boost\iterator\iterator_facade.hpp(549)
 : see reference to function template instantiation
 'boost::tuples::cons<HT,TT>
 boost::iterators::zip_iterator<IteratorTuple>::dereference(void) const'
 being compiled
 1> with
 1> [
 1> HT=char &,
 1> TT=boost::tuples::cons<char
 &,boost::fusion::detail::build_tuple_cons<boost::fusion::single_view_iterator<const
 boost::fusion::single_view<char
 &>,boost::mpl::int_<1>>,boost::fusion::single_view_iterator<const
 boost::fusion::single_view<char &>,boost::mpl::int_<1>>>::type>,
 1> IteratorTuple=iterators_t
 1> ]
 1> h:\develop\cpp\c++0x\vssandbox - 2011\main.cpp(8) : see
 reference to class template instantiation
 'boost::iterators::zip_iterator<IteratorTuple>' being compiled
 1> with
 1> [
 1> IteratorTuple=iterators_t
 1> ]
 1>c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(364): error C2039: 'iterator_category' : is not a
 member of '`global namespace''
 1>c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(364): error C2146: syntax error : missing ';'
 before identifier 'iterator_category'
 1>c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(364): error C2602:
 'std::iterator_traits<_Iter>::iterator_category' is not a member of a base
 class of 'std::iterator_traits<_Iter>'
 1> with
 1> [
 1> _Iter=char *const
 1> ]
 1> c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(364) : see declaration of
 'std::iterator_traits<_Iter>::iterator_category'
 1> with
 1> [
 1> _Iter=char *const
 1> ]
 1>c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(364): error C2868:
 'std::iterator_traits<_Iter>::iterator_category' : illegal syntax for
 using-declaration; expected qualified-name
 1> with
 1> [
 1> _Iter=char *const
 1> ]
 1>c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(365): error C2825: '_Iter': must be a class or
 namespace when followed by '::'
 1>c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(365): error C2039: 'value_type' : is not a member
 of '`global namespace''
 1>c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(365): error C2146: syntax error : missing ';'
 before identifier 'value_type'
 1>c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(365): error C2602:
 'std::iterator_traits<_Iter>::value_type' is not a member of a base class
 of 'std::iterator_traits<_Iter>'
 1> with
 1> [
 1> _Iter=char *const
 1> ]
 1> c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(365) : see declaration of
 'std::iterator_traits<_Iter>::value_type'
 1> with
 1> [
 1> _Iter=char *const
 1> ]
 1>c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(365): error C2868:
 'std::iterator_traits<_Iter>::value_type' : illegal syntax for using-
 declaration; expected qualified-name
 1> with
 1> [
 1> _Iter=char *const
 1> ]
 1>c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(366): error C2825: '_Iter': must be a class or
 namespace when followed by '::'
 1>c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(366): error C2039: 'difference_type' : is not a
 member of '`global namespace''
 1>c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(366): error C2146: syntax error : missing ';'
 before identifier 'difference_type'
 1>c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(366): error C2602:
 'std::iterator_traits<_Iter>::difference_type' is not a member of a base
 class of 'std::iterator_traits<_Iter>'
 1> with
 1> [
 1> _Iter=char *const
 1> ]
 1> c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(366) : see declaration of
 'std::iterator_traits<_Iter>::difference_type'
 1> with
 1> [
 1> _Iter=char *const
 1> ]
 1>c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(366): error C2868:
 'std::iterator_traits<_Iter>::difference_type' : illegal syntax for using-
 declaration; expected qualified-name
 1> with
 1> [
 1> _Iter=char *const
 1> ]
 1>c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(368): error C2825: '_Iter': must be a class or
 namespace when followed by '::'
 1>c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(368): error C2039: 'pointer' : is not a member of
 '`global namespace''
 1>c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(368): error C2146: syntax error : missing ';'
 before identifier 'pointer'
 1>c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(368): error C2602:
 'std::iterator_traits<_Iter>::pointer' is not a member of a base class of
 'std::iterator_traits<_Iter>'
 1> with
 1> [
 1> _Iter=char *const
 1> ]
 1> c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(368) : see declaration of
 'std::iterator_traits<_Iter>::pointer'
 1> with
 1> [
 1> _Iter=char *const
 1> ]
 1>c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(368): error C2868:
 'std::iterator_traits<_Iter>::pointer' : illegal syntax for using-
 declaration; expected qualified-name
 1> with
 1> [
 1> _Iter=char *const
 1> ]
 1>c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(369): error C2825: '_Iter': must be a class or
 namespace when followed by '::'
 1>c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(369): error C2039: 'reference' : is not a member
 of '`global namespace''
 1>c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(369): error C2146: syntax error : missing ';'
 before identifier 'reference'
 1>c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(369): error C2602:
 'std::iterator_traits<_Iter>::reference' is not a member of a base class
 of 'std::iterator_traits<_Iter>'
 1> with
 1> [
 1> _Iter=char *const
 1> ]
 1> c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(369) : see declaration of
 'std::iterator_traits<_Iter>::reference'
 1> with
 1> [
 1> _Iter=char *const
 1> ]
 1>c:\program files (x86)\microsoft visual studio
 11.0\vc\include\xutility(369): error C2868:
 'std::iterator_traits<_Iter>::reference' : illegal syntax for using-
 declaration; expected qualified-name
 1> with
 1> [
 1> _Iter=char *const
 1> ]
 1>c:\projects\thirdparty\boost_1_63_0\boost\fusion\adapted\boost_tuple\detail\build_cons.hpp(53):
 error C2440: 'initializing' : cannot convert from 'char *const ' to 'char
 &'
 ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
 }}}

 The problem seems rather severe to me and may occur even though the user-
 code didn't actually use zip_iterator directly. In fact I became aware of
 the problem when a colleague asked me why the following code would no
 longer be accepted when we switched from Boost 1.57 to Boost 1.63:

 {{{
 #include "boost/range/combine.hpp"

 int main()
 {
     int a[] = { 1, 2, 3 };
     int b[] = { 4, 5, 6 };

     for(const auto& p : boost::combine(a, b))
     {
     }
 }
 }}}

 According to my not fully completed analysis, the problem is caused,
 because the current implementation of zip_iterator::dereference relies on
 a recently introduced feature of std::iterator_traits being now sfinae-
 friendly (See LWG issue 2408), which is not the case in the VS 2012
 Standard Library. This assumption gets support by the fact that both VS
 2015 and VS 2017 accept the code (And both compiler's Standard Libraries
 provide sfinae-friendly iterator_traits).

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12895>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-03-10 21:34:05 UTC