From c8be00405539d8a202406939e159426fe7a7b2ad Mon Sep 17 00:00:00 2001 From: Olivier Parcollet Date: Mon, 23 Jun 2014 16:13:27 +0200 Subject: [PATCH] gf : bug correction in make_block_gf - See comment : a move + undefined order of args eval. of function error. --- triqs/gfs/block.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/triqs/gfs/block.hpp b/triqs/gfs/block.hpp index cd36b724..415983c3 100644 --- a/triqs/gfs/block.hpp +++ b/triqs/gfs/block.hpp @@ -103,7 +103,8 @@ namespace gfs { // from a vector of gf (moving directly) template block_gf make_block_gf(std::vector> V) { - return {{int(V.size())}, std::move(V), nothing{}, nothing{}, nothing{}}; + int s = V.size(); // DO NOT use V.size in next statement, the V is moved and the order of arg. evaluation is undefined. + return {{s}, std::move(V), nothing{}, nothing{}, nothing{}}; } // from a vector of gf : generalized to have a different type of gf in the vector (e.g. views...) @@ -154,7 +155,8 @@ namespace gfs { } template gf_view make_block_gf_view_from_vector(std::vector V) { - return {{int(V.size())}, std::move(V), nothing{}, nothing{}, nothing{}}; + int s = V.size(); + return {{s}, std::move(V), nothing{}, nothing{}, nothing{}}; } template