Commit 32de60bb authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-18749: Fix GCC -flifetime-dse

row_merge_create_fts_sort_index(): Initialize dict_col_t in
an unambiguous way. GCC 6 and later appear to be able to optimize
away the memset() that is part of mem_heap_zalloc() in the
placement new call. Let us avoid using placement new in order
to ensure that the objects will actually be initialized.

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

https://gcc.gnu.org/ml/gcc/2016-02/msg00207.html

While the latter reference hints that the optimization is only
applicable to non-POD types (and dict_col_t does not define
any member functions before 10.2), it is most consistent to
use the same initialization across all versions.
parent ea52ecbc
...@@ -98,8 +98,8 @@ row_merge_create_fts_sort_index( ...@@ -98,8 +98,8 @@ row_merge_create_fts_sort_index(
field = dict_index_get_nth_field(new_index, 0); field = dict_index_get_nth_field(new_index, 0);
field->name = NULL; field->name = NULL;
field->prefix_len = 0; field->prefix_len = 0;
field->col = new(mem_heap_zalloc(new_index->heap, sizeof(dict_col_t))) field->col = static_cast<dict_col_t*>(
dict_col_t(); mem_heap_zalloc(new_index->heap, sizeof(dict_col_t)));
field->col->prtype = idx_field->col->prtype | DATA_NOT_NULL; field->col->prtype = idx_field->col->prtype | DATA_NOT_NULL;
field->col->mtype = charset == &my_charset_latin1 field->col->mtype = charset == &my_charset_latin1
? DATA_VARCHAR : DATA_VARMYSQL; ? DATA_VARCHAR : DATA_VARMYSQL;
...@@ -113,8 +113,8 @@ row_merge_create_fts_sort_index( ...@@ -113,8 +113,8 @@ row_merge_create_fts_sort_index(
field = dict_index_get_nth_field(new_index, 1); field = dict_index_get_nth_field(new_index, 1);
field->name = NULL; field->name = NULL;
field->prefix_len = 0; field->prefix_len = 0;
field->col = new(mem_heap_zalloc(new_index->heap, sizeof(dict_col_t))) field->col = static_cast<dict_col_t*>(
dict_col_t(); mem_heap_zalloc(new_index->heap, sizeof(dict_col_t)));
field->col->mtype = DATA_INT; field->col->mtype = DATA_INT;
*opt_doc_id_size = FALSE; *opt_doc_id_size = FALSE;
...@@ -152,8 +152,8 @@ row_merge_create_fts_sort_index( ...@@ -152,8 +152,8 @@ row_merge_create_fts_sort_index(
field = dict_index_get_nth_field(new_index, 2); field = dict_index_get_nth_field(new_index, 2);
field->name = NULL; field->name = NULL;
field->prefix_len = 0; field->prefix_len = 0;
field->col = new(mem_heap_zalloc(new_index->heap, sizeof(dict_col_t))) field->col = static_cast<dict_col_t*>(
dict_col_t(); mem_heap_zalloc(new_index->heap, sizeof(dict_col_t)));
field->col->mtype = DATA_INT; field->col->mtype = DATA_INT;
field->col->len = 4 ; field->col->len = 4 ;
field->fixed_len = 4; field->fixed_len = 4;
......
...@@ -101,8 +101,8 @@ row_merge_create_fts_sort_index( ...@@ -101,8 +101,8 @@ row_merge_create_fts_sort_index(
field = dict_index_get_nth_field(new_index, 0); field = dict_index_get_nth_field(new_index, 0);
field->name = NULL; field->name = NULL;
field->prefix_len = 0; field->prefix_len = 0;
field->col = new(mem_heap_zalloc(new_index->heap, sizeof(dict_col_t))) field->col = static_cast<dict_col_t*>(
dict_col_t(); mem_heap_zalloc(new_index->heap, sizeof(dict_col_t)));
field->col->prtype = idx_field->col->prtype | DATA_NOT_NULL; field->col->prtype = idx_field->col->prtype | DATA_NOT_NULL;
field->col->mtype = charset == &my_charset_latin1 field->col->mtype = charset == &my_charset_latin1
? DATA_VARCHAR : DATA_VARMYSQL; ? DATA_VARCHAR : DATA_VARMYSQL;
...@@ -116,8 +116,8 @@ row_merge_create_fts_sort_index( ...@@ -116,8 +116,8 @@ row_merge_create_fts_sort_index(
field = dict_index_get_nth_field(new_index, 1); field = dict_index_get_nth_field(new_index, 1);
field->name = NULL; field->name = NULL;
field->prefix_len = 0; field->prefix_len = 0;
field->col = new(mem_heap_zalloc(new_index->heap, sizeof(dict_col_t))) field->col = static_cast<dict_col_t*>(
dict_col_t(); mem_heap_zalloc(new_index->heap, sizeof(dict_col_t)));
field->col->mtype = DATA_INT; field->col->mtype = DATA_INT;
*opt_doc_id_size = FALSE; *opt_doc_id_size = FALSE;
...@@ -155,8 +155,8 @@ row_merge_create_fts_sort_index( ...@@ -155,8 +155,8 @@ row_merge_create_fts_sort_index(
field = dict_index_get_nth_field(new_index, 2); field = dict_index_get_nth_field(new_index, 2);
field->name = NULL; field->name = NULL;
field->prefix_len = 0; field->prefix_len = 0;
field->col = new(mem_heap_zalloc(new_index->heap, sizeof(dict_col_t))) field->col = static_cast<dict_col_t*>(
dict_col_t(); mem_heap_zalloc(new_index->heap, sizeof(dict_col_t)));
field->col->mtype = DATA_INT; field->col->mtype = DATA_INT;
field->col->len = 4 ; field->col->len = 4 ;
field->fixed_len = 4; field->fixed_len = 4;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment