Subject: [Boost-bugs] [Boost C++ Libraries] #4528: Reference to stack memory associated with local variable 'x' returned
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-08-11 18:58:03
#4528: Reference to stack memory associated with local variable 'x' returned
-------------------------------+--------------------------------------------
Reporter: brian.doig@⦠| Owner: asutton
Type: Bugs | Status: new
Milestone: Boost 1.44.0 | Component: graph
Version: Boost 1.44.0 | Severity: Problem
Keywords: |
-------------------------------+--------------------------------------------
It looks like x is not being passed in by reference. Because of this a
copy is made on the stack. The operator returns x.value as a reference
which is dangerous since x will go out of scope.
This bug occurred with Xcode 4 beta 2, and with the latest version of
clang/llvm from the open source project.
CompileC /Users/bdoig/Library/Developer/Xcode/DerivedData/WDStoreTest-
dbsxxdunpvzihagbzjvgylinzzaf/Build/Intermediates/WDStoreTest.build/Debug-
iphonesimulator/WDStoreTest.build/Objects-normal/i386/TopoSort.o
/Users/bdoig/Dropbox/WData/TopoSort.mm normal i386 objective-c++
com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/bdoig/Dropbox/WDStoreTest
setenv LANG en_US.US-ASCII
setenv PATH
"/Xcode4/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Xcode4/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Xcode4/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang -x
objective-c++ -arch i386 -fmessage-length=0 -pipe -fdiagnostics-print-
source-range-info -fdiagnostics-show-category=id -Wno-trigraphs -fpascal-
strings -O0 -Wreturn-type -Wunused-variable
-D__IPHONE_OS_VERSION_MIN_REQUIRED=30200 -isysroot
/Xcode4/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk
-fasm-blocks -mmacosx-version-min=10.6 -gdwarf-2 -fvisibility=hidden
-fobjc-abi-version=2 -fobjc-legacy-dispatch -iquote
/Users/bdoig/Library/Developer/Xcode/DerivedData/WDStoreTest-
dbsxxdunpvzihagbzjvgylinzzaf/Build/Intermediates/WDStoreTest.build/Debug-
iphonesimulator/WDStoreTest.build/WDStoreTest-generated-files.hmap
-I/Users/bdoig/Library/Developer/Xcode/DerivedData/WDStoreTest-
dbsxxdunpvzihagbzjvgylinzzaf/Build/Intermediates/WDStoreTest.build/Debug-
iphonesimulator/WDStoreTest.build/WDStoreTest-own-target-headers.hmap
-I/Users/bdoig/Library/Developer/Xcode/DerivedData/WDStoreTest-
dbsxxdunpvzihagbzjvgylinzzaf/Build/Intermediates/WDStoreTest.build/Debug-
iphonesimulator/WDStoreTest.build/WDStoreTest-all-target-headers.hmap
-iquote /Users/bdoig/Library/Developer/Xcode/DerivedData/WDStoreTest-
dbsxxdunpvzihagbzjvgylinzzaf/Build/Intermediates/WDStoreTest.build/Debug-
iphonesimulator/WDStoreTest.build/WDStoreTest-project-headers.hmap
-F/Users/bdoig/Library/Developer/Xcode/DerivedData/WDStoreTest-
dbsxxdunpvzihagbzjvgylinzzaf/Build/Products/Debug-iphonesimulator
-I/Users/bdoig/Library/Developer/Xcode/DerivedData/WDStoreTest-
dbsxxdunpvzihagbzjvgylinzzaf/Build/Products/Debug-iphonesimulator/include
-I/Users/bdoig/Documents/Projects/boost_1_43_0
-I/Users/bdoig/Library/Developer/Xcode/DerivedData/WDStoreTest-
dbsxxdunpvzihagbzjvgylinzzaf/Build/Intermediates/WDStoreTest.build/Debug-
iphonesimulator/WDStoreTest.build/DerivedSources/i386
-I/Users/bdoig/Library/Developer/Xcode/DerivedData/WDStoreTest-
dbsxxdunpvzihagbzjvgylinzzaf/Build/Intermediates/WDStoreTest.build/Debug-
iphonesimulator/WDStoreTest.build/DerivedSources -include
/Users/bdoig/Library/Developer/Xcode/DerivedData/WDStoreTest-
dbsxxdunpvzihagbzjvgylinzzaf/Build/PrecompiledHeaders/WDStoreTest_Prefix-
bwcwseswayysywfpkcwdmibmtjef/WDStoreTest_Prefix.pch -c
/Users/bdoig/Dropbox/WData/TopoSort.mm -o
/Users/bdoig/Library/Developer/Xcode/DerivedData/WDStoreTest-
dbsxxdunpvzihagbzjvgylinzzaf/Build/Intermediates/WDStoreTest.build/Debug-
iphonesimulator/WDStoreTest.build/Objects-normal/i386/TopoSort.o
In file included from /Users/bdoig/Dropbox/WData/TopoSort.mm:11:
In file included from /Users/bdoig/Dropbox/WData/TopoSort.h:20:
In file included from
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/topological_sort.hpp:16:
In file included from
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/depth_first_search.hpp:21:
In file included from
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/named_function_params.hpp:15:
In file included from
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/parameter/name.hpp:8:
In file included from
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/parameter/keyword.hpp:10:
In file included from
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/parameter/aux_/tag.hpp:8:
In file included from
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/parameter/aux_/tagged_argument.hpp:10:
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/parameter/aux_/arg_list.hpp:127:16:{127:16-127:23}:
warning: reference to stack memory associated with local variable 'x'
returned [2]
return x.value;
^~~~~~~
In file included from /Users/bdoig/Dropbox/WData/TopoSort.mm:11:
In file included from /Users/bdoig/Dropbox/WData/TopoSort.h:20:
In file included from
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/topological_sort.hpp:16:
In file included from
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/depth_first_search.hpp:21:
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/named_function_params.hpp:408:19:
note: in instantiation of function template specialization
'boost::parameter::aux::empty_arg_list::operator[]<boost::graph::keywords::tag::vertex_index_map,
int const>' requested here [2]
>()(g, ap[t | 0]);
^
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/named_function_params.hpp:472:18:
note: in instantiation of function template specialization
'boost::detail::override_const_property<boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::graph::keywords::tag::visitor,
boost::topo_sort_visitor<std::front_insert_iterator<std::deque<int,
std::allocator<int> > > > const>,
boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::graph::keywords::tag::buffer,
int const>, boost::parameter::aux::empty_arg_list> >,
boost::graph::keywords::tag::vertex_index_map, boost::vertex_index_t,
boost::adjacency_list<boost::listS, boost::vecS, boost::directedS,
TopoVertexProperty, boost::no_property, boost::no_property, boost::listS>
>' requested here [2]
override_const_property(
^
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/named_function_params.hpp:496:24:
note: in instantiation of member function
'boost::detail::color_map_maker_helper<0,
boost::adjacency_list<boost::listS, boost::vecS, boost::directedS,
TopoVertexProperty, boost::no_property, boost::no_property, boost::listS>,
boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::graph::keywords::tag::visitor,
boost::topo_sort_visitor<std::front_insert_iterator<std::deque<int,
std::allocator<int> > > > const>,
boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::graph::keywords::tag::buffer,
int const>, boost::parameter::aux::empty_arg_list> >,
boost::default_color_type, int>::make_map' requested here [2]
return helper::make_map(g, white_color,
ap[boost::graph::keywords::_color_map | 0], ap);
^
In file included from /Users/bdoig/Dropbox/WData/TopoSort.mm:11:
In file included from /Users/bdoig/Dropbox/WData/TopoSort.h:20:
In file included from
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/topological_sort.hpp:16:
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/depth_first_search.hpp:300:72:
note: in instantiation of member function
'boost::detail::color_map_maker<boost::adjacency_list<boost::listS,
boost::vecS, boost::directedS, TopoVertexProperty, boost::no_property,
boost::no_property, boost::listS>,
boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::graph::keywords::tag::visitor,
boost::topo_sort_visitor<std::front_insert_iterator<std::deque<int,
std::allocator<int> > > > const>,
boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::graph::keywords::tag::buffer,
int const>, boost::parameter::aux::empty_arg_list> > >::make_map'
requested here [2]
boost::detail::color_map_maker<VertexListGraph,
arg_pack_type>::make_map(g, arg_pack),
^
In file included from /Users/bdoig/Dropbox/WData/TopoSort.mm:11:
In file included from /Users/bdoig/Dropbox/WData/TopoSort.h:20:
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/topological_sort.hpp:65:5:
note: in instantiation of function template specialization
'boost::depth_first_search<boost::adjacency_list<boost::listS,
boost::vecS, boost::directedS, TopoVertexProperty, boost::no_property,
boost::no_property, boost::listS>,
boost::topo_sort_visitor<std::front_insert_iterator<std::deque<int,
std::allocator<int> > > >, boost::graph_visitor_t,
boost::bgl_named_params<int, boost::buffer_param_t, boost::no_property> >'
requested here [2]
depth_first_search(g, params.visitor(TopoVisitor(result)));
^
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/topological_sort.hpp:71:5:
note: in instantiation of function template specialization
'boost::topological_sort<boost::adjacency_list<boost::listS, boost::vecS,
boost::directedS, TopoVertexProperty, boost::no_property,
boost::no_property, boost::listS>,
std::front_insert_iterator<std::deque<int, std::allocator<int> > >, int,
boost::buffer_param_t, boost::no_property>' requested here [2]
topological_sort(g, result,
^
/Users/bdoig/Dropbox/WData/TopoSort.mm:20:3: note: in instantiation of
function template specialization
'boost::topological_sort<boost::adjacency_list<boost::listS, boost::vecS,
boost::directedS, TopoVertexProperty, boost::no_property,
boost::no_property, boost::listS>,
std::front_insert_iterator<std::deque<int, std::allocator<int> > > >'
requested here [2]
boost::topological_sort(vectorList,
std::front_inserter(topo_order));
^
In file included from /Users/bdoig/Dropbox/WData/TopoSort.mm:11:
In file included from /Users/bdoig/Dropbox/WData/TopoSort.h:20:
In file included from
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/topological_sort.hpp:16:
In file included from
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/depth_first_search.hpp:21:
In file included from
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/named_function_params.hpp:15:
In file included from
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/parameter/name.hpp:8:
In file included from
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/parameter/keyword.hpp:10:
In file included from
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/parameter/aux_/tag.hpp:8:
In file included from
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/parameter/aux_/tagged_argument.hpp:10:
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/parameter/aux_/arg_list.hpp:127:16:{127:16-127:23}:
warning: reference to stack memory associated with local variable 'x'
returned [2]
return x.value;
^~~~~~~
In file included from /Users/bdoig/Dropbox/WData/TopoSort.mm:11:
In file included from /Users/bdoig/Dropbox/WData/TopoSort.h:20:
In file included from
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/topological_sort.hpp:16:
In file included from
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/depth_first_search.hpp:21:
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/named_function_params.hpp:496:49:
note: in instantiation of function template specialization
'boost::parameter::aux::empty_arg_list::operator[]<boost::graph::keywords::tag::color_map,
int const>' requested here [2]
return helper::make_map(g, white_color,
ap[boost::graph::keywords::_color_map | 0], ap);
^
In file included from /Users/bdoig/Dropbox/WData/TopoSort.mm:11:
In file included from /Users/bdoig/Dropbox/WData/TopoSort.h:20:
In file included from
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/topological_sort.hpp:16:
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/depth_first_search.hpp:300:72:
note: in instantiation of member function
'boost::detail::color_map_maker<boost::adjacency_list<boost::listS,
boost::vecS, boost::directedS, TopoVertexProperty, boost::no_property,
boost::no_property, boost::listS>,
boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::graph::keywords::tag::visitor,
boost::topo_sort_visitor<std::front_insert_iterator<std::deque<int,
std::allocator<int> > > > const>,
boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::graph::keywords::tag::buffer,
int const>, boost::parameter::aux::empty_arg_list> > >::make_map'
requested here [2]
boost::detail::color_map_maker<VertexListGraph,
arg_pack_type>::make_map(g, arg_pack),
^
In file included from /Users/bdoig/Dropbox/WData/TopoSort.mm:11:
In file included from /Users/bdoig/Dropbox/WData/TopoSort.h:20:
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/topological_sort.hpp:65:5:
note: in instantiation of function template specialization
'boost::depth_first_search<boost::adjacency_list<boost::listS,
boost::vecS, boost::directedS, TopoVertexProperty, boost::no_property,
boost::no_property, boost::listS>,
boost::topo_sort_visitor<std::front_insert_iterator<std::deque<int,
std::allocator<int> > > >, boost::graph_visitor_t,
boost::bgl_named_params<int, boost::buffer_param_t, boost::no_property> >'
requested here [2]
depth_first_search(g, params.visitor(TopoVisitor(result)));
^
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/topological_sort.hpp:71:5:
note: in instantiation of function template specialization
'boost::topological_sort<boost::adjacency_list<boost::listS, boost::vecS,
boost::directedS, TopoVertexProperty, boost::no_property,
boost::no_property, boost::listS>,
std::front_insert_iterator<std::deque<int, std::allocator<int> > >, int,
boost::buffer_param_t, boost::no_property>' requested here [2]
topological_sort(g, result,
^
/Users/bdoig/Dropbox/WData/TopoSort.mm:20:3: note: in instantiation of
function template specialization
'boost::topological_sort<boost::adjacency_list<boost::listS, boost::vecS,
boost::directedS, TopoVertexProperty, boost::no_property,
boost::no_property, boost::listS>,
std::front_insert_iterator<std::deque<int, std::allocator<int> > > >'
requested here [2]
boost::topological_sort(vectorList,
std::front_inserter(topo_order));
^
In file included from /Users/bdoig/Dropbox/WData/TopoSort.mm:11:
In file included from /Users/bdoig/Dropbox/WData/TopoSort.h:20:
In file included from
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/topological_sort.hpp:16:
In file included from
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/depth_first_search.hpp:21:
In file included from
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/named_function_params.hpp:15:
In file included from
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/parameter/name.hpp:8:
In file included from
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/parameter/keyword.hpp:10:
In file included from
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/parameter/aux_/tag.hpp:8:
In file included from
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/parameter/aux_/tagged_argument.hpp:10:
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/parameter/aux_/arg_list.hpp:127:16:{127:16-127:23}:
warning: reference to stack memory associated with local variable 'x'
returned [2]
return x.value;
^~~~~~~
In file included from /Users/bdoig/Dropbox/WData/TopoSort.mm:11:
In file included from /Users/bdoig/Dropbox/WData/TopoSort.h:20:
In file included from
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/topological_sort.hpp:16:
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/depth_first_search.hpp:301:8:
note: in instantiation of function template specialization
'boost::parameter::aux::empty_arg_list::operator[]<boost::graph::keywords::tag::root_vertex,
unsigned long const>' requested here [2]
arg_pack[_root_vertex | *vertices(g).first]
^
In file included from /Users/bdoig/Dropbox/WData/TopoSort.mm:11:
In file included from /Users/bdoig/Dropbox/WData/TopoSort.h:20:
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/topological_sort.hpp:65:5:
note: in instantiation of function template specialization
'boost::depth_first_search<boost::adjacency_list<boost::listS,
boost::vecS, boost::directedS, TopoVertexProperty, boost::no_property,
boost::no_property, boost::listS>,
boost::topo_sort_visitor<std::front_insert_iterator<std::deque<int,
std::allocator<int> > > >, boost::graph_visitor_t,
boost::bgl_named_params<int, boost::buffer_param_t, boost::no_property> >'
requested here [2]
depth_first_search(g, params.visitor(TopoVisitor(result)));
^
/Users/bdoig/Documents/Projects/boost_1_43_0/boost/graph/topological_sort.hpp:71:5:
note: in instantiation of function template specialization
'boost::topological_sort<boost::adjacency_list<boost::listS, boost::vecS,
boost::directedS, TopoVertexProperty, boost::no_property,
boost::no_property, boost::listS>,
std::front_insert_iterator<std::deque<int, std::allocator<int> > >, int,
boost::buffer_param_t, boost::no_property>' requested here [2]
topological_sort(g, result,
^
/Users/bdoig/Dropbox/WData/TopoSort.mm:20:3: note: in instantiation of
function template specialization
'boost::topological_sort<boost::adjacency_list<boost::listS, boost::vecS,
boost::directedS, TopoVertexProperty, boost::no_property,
boost::no_property, boost::listS>,
std::front_insert_iterator<std::deque<int, std::allocator<int> > > >'
requested here [2]
boost::topological_sort(vectorList,
std::front_inserter(topo_order));
^
3 warnings generated.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/4528> 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:04 UTC