Skip to content

Commit 9650811

Browse files
PS-9764 fix: Add clang-20 to Azure Pipelines and fix clang-20 compilation issues
https://perconadev.atlassian.net/browse/PS-9764 Fixed the following issue with calling 'memset()' on a nontrivially-constructed object ('TREE') by calling the placement new operator with empty brace initializer '{}' instead: /percona-server-8.0/storage/myisam/ft_boolean_search.cc:531:10: error: first argument in call to 'memset' is a pointer to non-trivially copyable type 'TREE' [-Werror,-Wnontrivial-memcall] 531 | memset(&ftb->no_dupes, 0, sizeof(TREE)); | ^ Fixed the following group of issues with calling 'memset()' on nontrivially-constructed objects ('TREE', 'MI_SORT_PARAM', 'MI_INFO') by declaring those objects with empty brace initializer '{}': /percona-server-8.0/storage/myisam/ft_nlq_search.cc:241:10: error: first argument in call to 'memset' is a pointer to non-trivially copyable type 'TREE' [-Werror,-Wnontrivial-memcall] 241 | memset(&wtree, 0, sizeof(wtree)); | ^ /home/yura/ws/percona-server-8.0/storage/myisam/myisamchk.cc:1404:10: error: first argument in call to 'memset' is a pointer to non-trivially copyable type 'MI_SORT_PARAM' [-Werror,-Wnontrivial-memcall] 1404 | memset(&sort_param, 0, sizeof(sort_param)); | ^ /home/yura/ws/percona-server-8.0/storage/myisam/mi_open.cc:122:10: error: first argument in call to 'memset' is a pointer to non-trivially copyable type 'MI_INFO' [-Werror,-Wnontrivial-memcall] 122 | memset(&info, 0, sizeof(info)); | ^ The following warning suppressed as it comes from the 'rocksdb' submodule code: /percona-server-8.0/storage/rocksdb/rocksdb/port/mmap.cc:46:15: error: first argument in call to 'memcpy' is a pointer to non-trivially copyable type 'rocksdb::MemMapping' [-Werror,-Wnontrivial-memcall] 46 | std::memcpy(this, &other, sizeof(*this)); | ^ Fixed the following literal operator warning: /percona-server-8.0/storage/temptable/include/temptable/constants.h:36:48: error: identifier '_KiB' preceded by whitespace in a literal operator declaration is deprecated [-Werror,-Wdeprecated-literal-operator] 36 | inline constexpr unsigned long long operator"" _KiB( | ~~~~~~~~~~~^~~~ | operator""_KiB Fixed the following extra semicolon warning in NDB code: /percona-server-8.0/storage/ndb/src/kernel/vm/Configuration.cpp:653:2: error: extra ';' outside of a function is incompatible with C++98 [-Werror,-Wc++98-compat-extra-semi] 653 | }; | ^ Removed adding '-Wno-enum-constexpr-conversion' to the compiler options for clang >= 18 for 'sql_gis' as this option no longer exists in the 'clang-20' and Oracle fixed this issue properly in Bug #36292498 "Compile MySQL with clang 18 [noclose]" (commit mysql/mysql-server@5e066e70ebb).
1 parent 112b7f9 commit 9650811

File tree

11 files changed

+16
-27
lines changed

11 files changed

+16
-27
lines changed

sql/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -962,11 +962,6 @@ ADD_DEPENDENCIES(sql_gis GenError)
962962
TARGET_LINK_LIBRARIES(sql_gis sql_dd sql_main)
963963
SET_TARGET_PROPERTIES(sql_gis PROPERTIES LINK_INTERFACE_MULTIPLICITY 3)
964964

965-
# Suppress warnings for clang-18 or newer
966-
IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18)
967-
TARGET_COMPILE_OPTIONS(sql_gis PRIVATE -Wno-enum-constexpr-conversion)
968-
ENDIF()
969-
970965
# This typically saves a few hundred megabytes of disk space.
971966
IF(COMPRESS_DEBUG_SECTIONS)
972967
MY_CHECK_CXX_COMPILER_FLAG("-gz" HAVE_COMPRESS_GZ_OPTION)

storage/myisam/ft_boolean_search.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ FT_INFO *ft_init_boolean_search(MI_INFO *info, uint keynr, uchar *query,
528528
assert(keynr == NO_SUCH_KEY || cs == info->s->keyinfo[keynr].seg->charset);
529529
ftb->with_scan = 0;
530530
ftb->lastpos = HA_OFFSET_ERROR;
531-
memset(&ftb->no_dupes, 0, sizeof(TREE));
531+
::new ((void *)&ftb->no_dupes) TREE{};
532532
ftb->last_word = nullptr;
533533

534534
::new ((void *)&ftb->mem_root) MEM_ROOT(PSI_INSTRUMENT_ME, 1024);

storage/myisam/ft_nlq_search.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ static int FT_DOC_cmp(void *, uchar *a_arg, uchar *b_arg) {
217217

218218
FT_INFO *ft_init_nlq_search(MI_INFO *info, uint keynr, uchar *query,
219219
uint query_len, uint flags, uchar *record) {
220-
TREE wtree;
220+
TREE wtree{};
221221
ALL_IN_ONE aio;
222222
FT_DOC *dptr;
223223
st_ft_info_nlq *dlist = nullptr;
@@ -238,8 +238,6 @@ FT_INFO *ft_init_nlq_search(MI_INFO *info, uint keynr, uchar *query,
238238
parser = info->s->keyinfo[keynr].parser;
239239
if (!(ftparser_param = ftparser_call_initializer(info, keynr, 0))) goto err;
240240

241-
memset(&wtree, 0, sizeof(wtree));
242-
243241
init_tree(&aio.dtree, 0, sizeof(FT_SUPERDOC), &FT_SUPERDOC_cmp, false,
244242
nullptr, nullptr);
245243

storage/myisam/ft_update.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,10 @@ uint _mi_ft_parse(TREE *parsed, MI_INFO *info, uint keynr, const uchar *record,
119119

120120
FT_WORD *_mi_ft_parserecord(MI_INFO *info, uint keynr, const uchar *record,
121121
MEM_ROOT *mem_root) {
122-
TREE ptree;
122+
TREE ptree{};
123123
MYSQL_FTPARSER_PARAM *param;
124124
DBUG_TRACE;
125125
if (!(param = ftparser_call_initializer(info, keynr, 0))) return nullptr;
126-
memset(&ptree, 0, sizeof(ptree));
127126
param->flags = 0;
128127
if (_mi_ft_parse(&ptree, info, keynr, record, param, mem_root))
129128
return nullptr;

storage/myisam/mi_check.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,11 +1412,10 @@ int mi_repair(MI_CHECK *param, MI_INFO *info, char *name, int rep_quick,
14121412
MYISAM_SHARE *share = info->s;
14131413
char llbuff[22], llbuff2[22];
14141414
SORT_INFO sort_info;
1415-
MI_SORT_PARAM sort_param;
1415+
MI_SORT_PARAM sort_param{};
14161416
DBUG_TRACE;
14171417

14181418
memset(&sort_info, 0, sizeof(sort_info));
1419-
memset(&sort_param, 0, sizeof(sort_param));
14201419
start_records = info->state->records;
14211420
new_header_length =
14221421
(param->testflag & T_UNPACK) ? 0L : share->pack.header_length;
@@ -2020,7 +2019,7 @@ int mi_repair_by_sort(MI_CHECK *param, MI_INFO *info, const char *name,
20202019
ha_rows start_records;
20212020
my_off_t new_header_length, del;
20222021
File new_file;
2023-
MI_SORT_PARAM sort_param;
2022+
MI_SORT_PARAM sort_param{};
20242023
MYISAM_SHARE *share = info->s;
20252024
HA_KEYSEG *keyseg;
20262025
ulong *rec_per_key_part;
@@ -2044,7 +2043,6 @@ int mi_repair_by_sort(MI_CHECK *param, MI_INFO *info, const char *name,
20442043
param->testflag |= T_CALC_CHECKSUM;
20452044

20462045
memset(&sort_info, 0, sizeof(sort_info));
2047-
memset(&sort_param, 0, sizeof(sort_param));
20482046
if (!(sort_info.key_block =
20492047
alloc_key_blocks(param, (uint)param->sort_key_blocks,
20502048
share->base.max_key_block_length)) ||

storage/myisam/mi_open.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ MI_INFO *mi_open_share(const char *name, MYISAM_SHARE *old_share, int mode,
106106
char name_buff[FN_REFLEN], org_name[FN_REFLEN], index_name[FN_REFLEN],
107107
data_name[FN_REFLEN];
108108
uchar *disk_cache, *disk_pos, *end_pos;
109-
MI_INFO info, *m_info;
109+
MI_INFO info{}, *m_info;
110110
MYISAM_SHARE share_buff, *share;
111111
ulong rec_per_key_part[HA_MAX_POSSIBLE_KEY * MI_MAX_KEY_SEG];
112112
my_off_t key_root[HA_MAX_POSSIBLE_KEY], key_del[MI_MAX_KEY_BLOCK_SIZE];
@@ -119,7 +119,6 @@ MI_INFO *mi_open_share(const char *name, MYISAM_SHARE *old_share, int mode,
119119
lock_error = 1;
120120
errpos = 0;
121121
head_length = sizeof(share_buff.state.header);
122-
memset(&info, 0, sizeof(info));
123122

124123
realpath_err = my_realpath(
125124
name_buff, fn_format(org_name, name, "", MI_NAME_IEXT, 4), MYF(0));

storage/myisam/myisamchk.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,11 +1397,10 @@ static int mi_sort_records(MI_CHECK *param, MI_INFO *info, char *name,
13971397
MYISAM_SHARE *share = info->s;
13981398
char llbuff[22], llbuff2[22];
13991399
SORT_INFO sort_info;
1400-
MI_SORT_PARAM sort_param;
1400+
MI_SORT_PARAM sort_param{};
14011401
DBUG_TRACE;
14021402

14031403
memset(&sort_info, 0, sizeof(sort_info));
1404-
memset(&sort_param, 0, sizeof(sort_param));
14051404
sort_param.sort_info = &sort_info;
14061405
sort_info.param = param;
14071406
keyinfo = &share->keyinfo[sort_key];

storage/ndb/src/kernel/vm/Configuration.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,15 +650,15 @@ void Configuration::setMixologyLevel(Uint32 l) { _mixologyLevel = l; }
650650

651651
Uint32 Configuration::getShutdownHandlingFault() const {
652652
return _shutdownHandlingFault;
653-
};
653+
}
654654
Uint32 Configuration::getShutdownHandlingFaultExtra() const {
655655
return _shutdownHandlingFaultExtra;
656-
};
656+
}
657657

658658
void Configuration ::setShutdownHandlingFault(Uint32 v, Uint32 extra) {
659659
_shutdownHandlingFault = v;
660660
_shutdownHandlingFaultExtra = extra;
661-
};
661+
}
662662

663663
#endif
664664

storage/rocksdb/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
229229
remove_compile_flags(-Wdeprecated -Winconsistent-missing-destructor-override -Wnon-virtual-dtor)
230230
ADD_CXX_COMPILE_FLAGS_TO_FILES(-Wno-shadow-field FILES ha_rocksdb.cc rocksdb/memtable/hash_skiplist_rep.cc)
231231
ADD_CXX_COMPILE_FLAGS_TO_FILES(-Wno-conditional-uninitialized FILES ha_rocksdb.cc rdb_datadic.cc rocksdb/db/db_impl/db_impl.cc rocksdb/db/write_thread.cc rocksdb/env/env_posix.cc rocksdb/env/fs_posix.cc)
232+
ADD_CXX_COMPILE_FLAGS_TO_FILES(-Wno-nontrivial-memcall FILES rocksdb/port/mmap.cc)
232233
ENDIF()
233234

234235
# Suppress warnings for clang-9 or older

storage/temptable/include/temptable/constants.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,23 @@ namespace temptable {
3333

3434
/** Multiply a number by 1024.
3535
* @return n * 1024. */
36-
inline constexpr unsigned long long operator"" _KiB(
36+
inline constexpr unsigned long long operator""_KiB(
3737
/** [in] Number to multiply. */
3838
unsigned long long n) {
3939
return n << 10;
4040
}
4141

4242
/** Multiply a number by 1024 * 1024.
4343
* @return n * 1024 * 1024. */
44-
inline constexpr unsigned long long operator"" _MiB(
44+
inline constexpr unsigned long long operator""_MiB(
4545
/** [in] Number to multiply. */
4646
unsigned long long n) {
4747
return n << 20;
4848
}
4949

5050
/** Multiply a number by 1024 * 1024 * 1024.
5151
* @return n * 1024 * 1024 * 1024. */
52-
inline constexpr unsigned long long operator"" _GiB(
52+
inline constexpr unsigned long long operator""_GiB(
5353
/** [in] Number to multiply. */
5454
unsigned long long n) {
5555
return n << 30;

0 commit comments

Comments
 (0)