Skip to content
Permalink
Browse files
MDEV-18878: Fix GCC -flifetime-dse
GCC 6 and later can optimize away the memset() that is part of
mem_heap_zalloc() in a placement new call. So, instead of relying
on that kind of initialization, explicitly initialize the necessary
fields in the constructors.

que_common_t::que_common_t(): Initialize more fields in the
default constructor.

purge_vcol_info_t::purge_vcol_info_t(): Initialize all fields in
the default constructor.

purge_node_t::purge_node_t(): Initialize all necessary fields.

Reference:

    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71388

    https://gcc.gnu.org/ml/gcc/2016-02/msg00207.html
  • Loading branch information
dr-m committed Mar 12, 2019
1 parent e374755 commit e070cfe
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
@@ -87,8 +87,9 @@ struct que_common_t{
explicitly */

/** Constructor */
que_common_t(ulint type, que_node_t* parent)
: type(type), parent(parent), brother(), val(), val_buf_size()
que_common_t(ulint type, que_node_t* parent) :
type(type), parent(parent), brother(NULL),
val(), val_buf_size(0)
{}
};

@@ -133,7 +133,14 @@ struct purge_node_t{

/** Constructor */
explicit purge_node_t(que_thr_t* parent) :
common(QUE_NODE_PURGE, parent), heap(mem_heap_create(256))
common(QUE_NODE_PURGE, parent),
undo_recs(NULL),
unavailable_table_id(0),
heap(mem_heap_create(256)),
#ifdef UNIV_DEBUG
in_progress(false),
#endif
vcol_info()
{}

#ifdef UNIV_DEBUG
@@ -69,6 +69,11 @@ struct purge_vcol_info_t
TABLE* mariadb_table;

public:
/** Default constructor */
purge_vcol_info_t() :
requested(false), used(false), first_use(false),
mariadb_table(NULL)
{}
/** Reset the state. */
void reset()
{
@@ -182,7 +182,7 @@ purge_graph_build()

for (ulint i = 0; i < srv_n_purge_threads; ++i) {
que_thr_t* thr = que_thr_create(fork, heap, NULL);
thr->child = new(mem_heap_zalloc(heap, sizeof(purge_node_t)))
thr->child = new(mem_heap_alloc(heap, sizeof(purge_node_t)))
purge_node_t(thr);
}

0 comments on commit e070cfe

Please sign in to comment.