Skip to content

Commit 8a8e42e

Browse files
committed
Work around spurious warning raised up to GCC 6.5
GCC complains: ../util/irep.h:247:21: error: ‘*((void*)(& __val)+8).irept::data’ may be used uninitialized in this function [-Werror=maybe-uninitialized] remove_ref(data); GCC 7 and later are fine without this hack.
1 parent 6b2b950 commit 8a8e42e

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

src/goto-programs/remove_virtual_functions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ void remove_virtual_functionst::get_child_functions_rec(
399399
}
400400
}
401401
functions.push_back(function);
402-
entry_map.insert({child, function});
402+
entry_map.emplace(child, function);
403403

404404
get_child_functions_rec(
405405
child,

src/goto-programs/remove_virtual_functions.h

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,34 @@ enum class virtual_dispatch_fallback_actiont
5454
class dispatch_table_entryt
5555
{
5656
public:
57-
dispatch_table_entryt() = default;
58-
explicit dispatch_table_entryt(const irep_idt &_class_id)
59-
: class_id(_class_id)
60-
{}
61-
62-
optionalt<symbol_exprt> symbol_expr;
63-
irep_idt class_id;
57+
explicit dispatch_table_entryt(const irep_idt &_class_id)
58+
: symbol_expr(), class_id(_class_id)
59+
{}
60+
61+
#if defined(__GNUC__) && __GNUC__ < 7
62+
// GCC up to version 6.5 warns about irept::data being used uninitialized upon
63+
// the move triggered by std::sort; using operator= works around this
64+
dispatch_table_entryt(dispatch_table_entryt &&other)
65+
{
66+
symbol_expr = other.symbol_expr;
67+
class_id = other.class_id;
68+
}
69+
70+
dispatch_table_entryt &operator=(const dispatch_table_entryt &other)
71+
{
72+
symbol_expr = other.symbol_expr;
73+
class_id = other.class_id;
74+
return *this;
75+
}
76+
77+
dispatch_table_entryt(const dispatch_table_entryt &other)
78+
: symbol_expr(other.symbol_expr), class_id(other.class_id)
79+
{
80+
}
81+
#endif
82+
83+
optionalt<symbol_exprt> symbol_expr;
84+
irep_idt class_id;
6485
};
6586

6687
typedef std::vector<dispatch_table_entryt> dispatch_table_entriest;

0 commit comments

Comments
 (0)