Re: [Boost-bugs] [Boost C++ Libraries] #10493: Since 1.56, any_range with non-reference references can cause UB

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #10493: Since 1.56, any_range with non-reference references can cause UB
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-09-07 13:05:11


#10493: Since 1.56, any_range with non-reference references can cause UB
---------------------------+------------------------
  Reporter: nofitserov@… | Owner: neilgroves
      Type: Bugs | Status: assigned
 Milestone: Boost 1.58.0 | Component: range
   Version: Boost 1.56.0 | Severity: Regression
Resolution: | Keywords:
---------------------------+------------------------

Comment (by Tobias Reh <treh@…>):

 Still present in 1.59.0

 The problem is becoming more visible with MSVC++2015 because the compiler
 is better in detecting dangling references and emitting errors for them.
 To hard code those checks, just add the following assert into every
 {{{dereference()}}} method in range/detail/any_iterator_wrapper.hpp:

 {{{#!c++
 static_assert(
    !std::is_lvalue_reference<reference>::value
    || std::is_lvalue_reference<decltype(*m_it)>::value,
    "dangling ref"
 );
 }}}

 A little bit of digging in the headers shows that the problem lies in
 range/detail/any_iterator_interface.hpp, where
 any_incrementable_iterator_interface's
 {{{#!c++
 typedef Reference reference;
 }}}
 was changed in 1.56.0 to
 {{{#!c++
 typedef typename mutable_reference_type_generator<
     Reference
>::type reference;
 }}}

 Rolling this back solves the problem for our codebase. Any possibilities
 of having this fixed soon?

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10493#comment:5>
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-02-16 18:50:19 UTC