From 2f32aee59e874b32360f5df2f79d628e668d6567 Mon Sep 17 00:00:00 2001 From: Nathan Phillips Date: Wed, 25 Oct 2017 15:55:41 +0100 Subject: [PATCH] Fixed scope of moved symbol Because symbol was declared in outer scope it was being reused after being moved. In practice this was not causing problems, but to avoid headaches it is better to move it to the loop scope so that it is reinitialised before being reused after being moved. --- src/util/fresh_symbol.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/util/fresh_symbol.cpp b/src/util/fresh_symbol.cpp index e1795890721..596fb245440 100644 --- a/src/util/fresh_symbol.cpp +++ b/src/util/fresh_symbol.cpp @@ -38,19 +38,15 @@ symbolt &get_fresh_aux_symbol( const irep_idt &symbol_mode, symbol_tablet &symbol_table) { - auxiliary_symbolt new_symbol; - // Loop until find a name that doesn't clash with a non-auxilliary symbol while(true) { - // Distinguish local variables with the same name - new_symbol.base_name= - basename_prefix+"$"+std::to_string(++temporary_counter); - if(name_prefix.empty()) - new_symbol.name=new_symbol.base_name; - else + auxiliary_symbolt new_symbol( + // Distinguish local variables with the same name + basename_prefix + "$" + std::to_string(++temporary_counter), + type); + if(!name_prefix.empty()) new_symbol.name=name_prefix+"::"+id2string(new_symbol.base_name); - new_symbol.type=type; new_symbol.location=source_location; new_symbol.mode=symbol_mode; std::pair res=symbol_table.insert(std::move(new_symbol));