From fb5954f7b08c98eee41a2b59a1e89ab10569510a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 4 Sep 2016 15:01:38 +0200 Subject: Fix initializer list lifetime issues --- build2/cc/compile.cxx | 8 ++------ build2/cc/link.cxx | 24 ++++++++++-------------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/build2/cc/compile.cxx b/build2/cc/compile.cxx index 39856df..c4df30f 100644 --- a/build2/cc/compile.cxx +++ b/build2/cc/compile.cxx @@ -1576,14 +1576,10 @@ namespace build2 { file& t (static_cast (xt)); - initializer_list e; - if (cid == "msvc") - e = {".d", ".idb", ".pdb"}; + return clean_extra (a, t, {".d", ".idb", ".pdb"}); else - e = {".d"}; - - return clean_extra (a, t, e); + return clean_extra (a, t, {".d"}); } } } diff --git a/build2/cc/link.cxx b/build2/cc/link.cxx index 29a46b4..5a8dcb7 100644 --- a/build2/cc/link.cxx +++ b/build2/cc/link.cxx @@ -1606,7 +1606,6 @@ namespace build2 file& t (static_cast (xt)); libs_paths paths; - initializer_list> e {{".d"}}; // Default. switch (link_type (t)) { @@ -1617,16 +1616,14 @@ namespace build2 if (tclass == "windows") { if (tsys == "mingw32") - { - e = {{".d", ".dlls/", ".manifest.o", ".manifest"}}; - } + return clean_extra ( + a, t, {".d", ".dlls/", ".manifest.o", ".manifest"}); else - { // Assuming it's VC or alike. Clean up .ilk in case the user // enabled incremental linking (note that .ilk replaces .exe). // - e = {{".d", ".dlls/", ".manifest", "-.ilk"}}; - } + return clean_extra ( + a, t, {".d", ".dlls/", ".manifest", "-.ilk"}); } break; @@ -1641,7 +1638,7 @@ namespace build2 // versioning their bases may not be the same. // if (tsys != "mingw32") - e = {{".d", "-.ilk"}, {"-.exp"}}; + return clean_extra (a, t, {{".d", "-.ilk"}, {"-.exp"}}); } else { @@ -1649,18 +1646,17 @@ namespace build2 // the paths are empty, then they will be ignored. // paths = derive_libs_paths (t); - - e = {{".d", - paths.link.string ().c_str (), - paths.soname.string ().c_str (), - paths.interm.string ().c_str ()}}; + return clean_extra (a, t, {".d", + paths.link.string ().c_str (), + paths.soname.string ().c_str (), + paths.interm.string ().c_str ()}); } break; } } - return clean_extra (a, t, e); + return clean_extra (a, t, {".d"}); } } } -- cgit v1.1