Skip to content

Commit 2f32aee

Browse files
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.
1 parent 5057c57 commit 2f32aee

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/util/fresh_symbol.cpp

+5-9
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,15 @@ symbolt &get_fresh_aux_symbol(
3838
const irep_idt &symbol_mode,
3939
symbol_tablet &symbol_table)
4040
{
41-
auxiliary_symbolt new_symbol;
42-
4341
// Loop until find a name that doesn't clash with a non-auxilliary symbol
4442
while(true)
4543
{
46-
// Distinguish local variables with the same name
47-
new_symbol.base_name=
48-
basename_prefix+"$"+std::to_string(++temporary_counter);
49-
if(name_prefix.empty())
50-
new_symbol.name=new_symbol.base_name;
51-
else
44+
auxiliary_symbolt new_symbol(
45+
// Distinguish local variables with the same name
46+
basename_prefix + "$" + std::to_string(++temporary_counter),
47+
type);
48+
if(!name_prefix.empty())
5249
new_symbol.name=name_prefix+"::"+id2string(new_symbol.base_name);
53-
new_symbol.type=type;
5450
new_symbol.location=source_location;
5551
new_symbol.mode=symbol_mode;
5652
std::pair<symbolt &, bool> res=symbol_table.insert(std::move(new_symbol));

0 commit comments

Comments
 (0)