Skip to content

Commit

Permalink
Merge pull request percona#4296 from inikep/PS-7694-5.7
Browse files Browse the repository at this point in the history
PS-7694 [5.7]: Fix compilation issues with gcc-11
  • Loading branch information
inikep authored May 12, 2021
2 parents 4a26f53 + 6b309f4 commit ade7df4
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 7 deletions.
8 changes: 8 additions & 0 deletions libmysqld/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@ IF(HAVE_MISLEADING_INDENTATION)
COMPILE_FLAGS "-Wno-misleading-indentation")
ENDIF()

# Suppress warnings for gcc-11 or newer
IF(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11)
ADD_CXX_COMPILE_FLAGS_TO_FILES(-Wno-array-bounds FILES ../sql/spatial.cc)
ADD_CXX_COMPILE_FLAGS_TO_FILES(-Wno-stringop-overflow FILES ../sql/spatial.cc)
# a false positive with a bison-generated file (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98753)
ADD_CXX_COMPILE_FLAGS_TO_FILES(-Wno-free-nonheap-object FILES ${CMAKE_CURRENT_BINARY_DIR}/sql_hints.yy.cc)
ENDIF()

# Handle out-of-source build from source package with possibly broken
# bison. Copy bison output to from source to build directory, if not already
# there
Expand Down
1 change: 1 addition & 0 deletions mysys/thr_lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1389,6 +1389,7 @@ static void *test_thread(void *arg)
THR_LOCK_DATA *multi_locks[MAX_LOCK_COUNT];
my_thread_id id;
mysql_cond_t COND_thr_lock;
memset(&COND_thr_lock, 0, sizeof(COND_thr_lock));

id= param + 1; /* Main thread uses value 0. */
mysql_cond_init(0, &COND_thr_lock);
Expand Down
8 changes: 8 additions & 0 deletions sql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,14 @@ IF (WIN32 AND OPENSSL_APPLINK_C)
)
ENDIF()

# Suppress warnings for gcc-11 or newer
IF(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11)
ADD_CXX_COMPILE_FLAGS_TO_FILES(-Wno-array-bounds FILES spatial.cc)
ADD_CXX_COMPILE_FLAGS_TO_FILES(-Wno-stringop-overflow FILES spatial.cc)
# a false positive with a bison-generated file (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98753)
ADD_CXX_COMPILE_FLAGS_TO_FILES(-Wno-free-nonheap-object FILES ${CMAKE_CURRENT_BINARY_DIR}/sql_hints.yy.cc)
ENDIF()

ADD_CONVENIENCE_LIBRARY(sql ${SQL_SOURCE})
ADD_DEPENDENCIES(sql GenServerSource)
ADD_DEPENDENCIES(sql GenDigestServerSource)
Expand Down
3 changes: 1 addition & 2 deletions sql/item_geofunc_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ merge_components(my_bool *pnull_value)
if (is_comp_no_overlapped())
return;

POS pos;
Item_func_spatial_operation ifso(pos, NULL, NULL,
Item_func_spatial_operation ifso(POS(), NULL, NULL,
Item_func_spatial_operation::op_union);
bool do_again= true;
uint32 last_composition[6]= {0}, num_unchanged_composition= 0;
Expand Down
4 changes: 2 additions & 2 deletions sql/opt_range.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14904,7 +14904,7 @@ static void append_range_all_keyparts(Opt_trace_array *range_trace,
range_string and the string becomes too long. Printing very long
range conditions normally doesn't make sense either.
*/
if (!append_to_trace && range_string->length() > 500)
if (!append_to_trace && range_string && range_string->length() > 500)
{
range_string->append(STRING_WITH_LEN("..."));
break;
Expand Down Expand Up @@ -14942,7 +14942,7 @@ static void append_range_all_keyparts(Opt_trace_array *range_trace,
if (append_to_trace)
range_trace->add_utf8(range_so_far->ptr(),
range_so_far->length());
else
else if (range_string)
{
if (range_string->length() == 0)
range_string->append(STRING_WITH_LEN("("));
Expand Down
6 changes: 6 additions & 0 deletions storage/innobase/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ IF(HAVE_CAST_FUNCTION_TYPE)
COMPILE_FLAGS "-Wno-cast-function-type")
ENDIF()

# Suppress warnings for gcc-11 or newer
IF(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11)
# a false positive with a bison-generated file (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98753)
ADD_CXX_COMPILE_FLAGS_TO_FILES(-Wno-free-nonheap-object FILES pars/pars0grm.cc)
ENDIF()

# A GCC bug causes crash when compiling these files on ARM64 with -O1+
# Compile them with -O0 as a workaround.
IF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
Expand Down
2 changes: 2 additions & 0 deletions storage/innobase/include/mem0mem.ic
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,8 @@ mem_strdupl(
ulint len) /*!< in: length of str, in bytes */
{
char* s = static_cast<char*>(ut_malloc_nokey(len + 1));
if (!s) return NULL;

s[len] = 0;
if (len > 0) {
memcpy(s, str, len);
Expand Down
6 changes: 3 additions & 3 deletions testclients/mysql_client_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -18146,9 +18146,9 @@ static void test_bug40365(void)
if (!opt_silent)
fprintf(stdout, "\ntime[%d]: %02d-%02d-%02d ",
i, tm[i].year, tm[i].month, tm[i].day);
DIE_UNLESS(tm[i].year == 0);
DIE_UNLESS(tm[i].month == 0);
DIE_UNLESS(tm[i].day == 0);
DIE_UNLESS(tm[i].year == 0);
DIE_UNLESS(tm[i].month == 0);
DIE_UNLESS(tm[i].day == 0);
}
mysql_stmt_close(stmt);
rc= mysql_commit(mysql);
Expand Down
2 changes: 2 additions & 0 deletions unittest/gunit/strings_utf8-t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ TEST_F(StringsUTF8Test, MyIsmbcharUtf8)

/* valid utf8 charaters, testing for boundry values */
utf8_src[0]= '\x00';
utf8_src[1]= '\x00';
EXPECT_EQ(0U, system_charset_info->cset->ismbchar(system_charset_info,
utf8_src, utf8_src + 1));

Expand Down Expand Up @@ -366,6 +367,7 @@ TEST_F(StringsUTF8mb4Test, MyIsmbcharUtf8mb4)

/* valid utf8mb4 charaters, testing for boundry values */
utf8_src[0]= '\x00';
utf8_src[1]= '\x00';
EXPECT_EQ(0U, system_charset_info->cset->ismbchar(system_charset_info,
utf8_src,utf8_src + 1));
utf8_src[0]= '\x7f';
Expand Down

0 comments on commit ade7df4

Please sign in to comment.