[Boost-bugs] [Boost C++ Libraries] #12272: vertex_iterator dereference has odd return value

Subject: [Boost-bugs] [Boost C++ Libraries] #12272: vertex_iterator dereference has odd return value
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-06-15 16:22:37


#12272: vertex_iterator dereference has odd return value
------------------------------+----------------------
 Reporter: ich.freak@… | Owner: jewillco
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: graph
  Version: Boost 1.61.0 | Severity: Problem
 Keywords: |
------------------------------+----------------------
 graph_traits::vertex_iterator::operator* seems to not return Value& as it
 should. This not only differs from STL iterators but can and does easily
 cause segfaults.

 {{{
 #!div style="font-size: 80%"
 Code highlighting:
   {{{#!cpp
 #include<list>
 #include<boost/graph/adjacency_list.hpp>

 typedef boost::adjacency_list<boost::vecS,boost::vecS> Graph;
 typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;
 typedef boost::graph_traits<Graph>::vertex_iterator VIter;

 const Vertex& deref(const VIter& it){
   return *it; // warning: returning reference to temporary [-Wreturn-
 local-addr]
 }

 const Vertex& deref(const std::list<Vertex>::iterator& it){
   return *it; // no warning, works fine
 }


 int main(){
   Graph g;
   Vertex u = boost::add_vertex(g);
   Vertex v = deref(boost::vertices(g).first);

   std::list<Vertex> vl(1, u);
   Vertex w = deref(vl.begin());

   return 0;
 }
   }}}
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12272>
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:20 UTC