Skip to content

Commit f71df24

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 f71df24

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
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: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,33 @@ enum class virtual_dispatch_fallback_actiont
5353

5454
class dispatch_table_entryt
5555
{
56-
public:
57-
dispatch_table_entryt() = default;
56+
public:
5857
explicit dispatch_table_entryt(const irep_idt &_class_id)
59-
: class_id(_class_id)
60-
{}
58+
: symbol_expr(), class_id(_class_id)
59+
{
60+
}
61+
62+
#if defined(__GNUC__) && __GNUC__ < 7
63+
// GCC up to version 6.5 warns about irept::data being used uninitialized upon
64+
// the move triggered by std::sort; using operator= works around this
65+
dispatch_table_entryt(dispatch_table_entryt &&other)
66+
{
67+
symbol_expr = other.symbol_expr;
68+
class_id = other.class_id;
69+
}
70+
71+
dispatch_table_entryt &operator=(const dispatch_table_entryt &other)
72+
{
73+
symbol_expr = other.symbol_expr;
74+
class_id = other.class_id;
75+
return *this;
76+
}
77+
78+
dispatch_table_entryt(const dispatch_table_entryt &other)
79+
: symbol_expr(other.symbol_expr), class_id(other.class_id)
80+
{
81+
}
82+
#endif
6183

6284
optionalt<symbol_exprt> symbol_expr;
6385
irep_idt class_id;

0 commit comments

Comments
 (0)