From c9c865ff4b6c235c1a5a46d03c8812e9a8468a35 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <github@naumov.de> Date: Sun, 16 Jun 2019 17:18:41 +0200 Subject: [PATCH] [A/U] Store value instead of reference. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since at least gcc-9.1 the original code didn't compile any longer with error message: computeSurfaceNodeIDsInPolygonalRegion.cpp:147:48: error: converting to ‘const GeoLib::Polygon’ from initializer list would use explicit constructor ‘GeoLib::Polygon::Polygon(const GeoLib::Polyline&, bool)’ 147 | GeoLib::Polygon const& polygon{*plys[j]}; | ^ From reference_initialization page of cppreference.com: Lifetime of a temporary: ... - a temporary bound to a reference member in a constructor initializer list persists only until the constructor exits, not as long as the object exists. (note: such initialization is ill-formed as of DR 1696). --- .../MeshGeoTools/computeSurfaceNodeIDsInPolygonalRegion.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Applications/Utils/MeshGeoTools/computeSurfaceNodeIDsInPolygonalRegion.cpp b/Applications/Utils/MeshGeoTools/computeSurfaceNodeIDsInPolygonalRegion.cpp index 8cd31a738fd..96fdbf67d00 100644 --- a/Applications/Utils/MeshGeoTools/computeSurfaceNodeIDsInPolygonalRegion.cpp +++ b/Applications/Utils/MeshGeoTools/computeSurfaceNodeIDsInPolygonalRegion.cpp @@ -144,7 +144,7 @@ int main (int argc, char* argv[]) polygon_name = "Polygon-" + std::to_string(j); } // create Polygon from Polyline - GeoLib::Polygon const& polygon{*plys[j]}; + GeoLib::Polygon const polygon{*plys[j]}; // ids of mesh nodes on surface that are within the given polygon std::vector<std::pair<std::size_t, double>> ids_and_areas; for (std::size_t k(0); k<all_sfc_nodes.size(); k++) { -- GitLab