Subject: Re: [Boost-bugs] [Boost C++ Libraries] #8489: Unnecessary Definition of iterator_adaptor.hpp class Has Dangerous Return of Temporary Object
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-04-25 14:40:09
#8489: Unnecessary Definition of iterator_adaptor.hpp class Has Dangerous Return
of Temporary Object
----------------------------------------------------+-----------------------
Reporter: Jeffrey D. Oldham <oldham@â¦> | Owner: jeffrey.hellrung
Type: Bugs | Status: new
Milestone: To Be Determined | Component: iterator
Version: Boost 1.53.0 | Severity: Problem
Resolution: | Keywords:
----------------------------------------------------+-----------------------
Comment (by oldham@â¦):
If my logic is correct, the return type for
iterator_adaptor::dereference() is:
* Reference if Reference != use_default,
* iterator_reference<Base> if Reference == use_default and Value ==
use_default,
* add_reference<Value> if Reference == use_default and Value !=
use_default.
I conjecture
* the second case is not causing problems and
* the third case is causing problems for the example program. For a
slight variant of the program, I believe Value == const char and Reference
== use_default. Thus, it tries to return a const char& which causes a
local temporary to be created and then a reference returned.
One possible implementation solution is to specialize iterator_adaptor<>
so dereference has a declaration with no definition for the third case.
Another is to modify iterator_adaptor_base so problematic third cases do
not occur.
It is not clear what to do.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/8489#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:12 UTC