From 5cab2078f85aeca5e734ea08eb4285ed21b8227a Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 24 May 2016 22:36:20 +0100 Subject: [PATCH] Fix string view created from a temporary string This is clearly a case where rust style lifetime analysis would have been nice, hopefully it comes with GSL lifetime extensions... Fixes #680 --- src/commands.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/commands.cc b/src/commands.cc index 56a94430..8f552170 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -1871,8 +1871,7 @@ const CommandDesc change_working_directory_cmd = { }}, [](const ParametersParser& parser, Context&, const ShellContext&) { - - StringView target = parser.positional_count() == 1 ? parser[0] : "~"; + StringView target = parser.positional_count() == 1 ? StringView{parser[0]} : "~"; if (chdir(parse_filename(target).c_str()) != 0) throw runtime_error(format("cannot change to directory '{}'", target)); for (auto& buffer : BufferManager::instance())