Bug #108870 Dead code discovered with clang-15 compiler
Submitted: 25 Oct 2022 12:07 Modified: 7 Nov 2022 13:34
Reporter: Yura Sorokin (OCA) Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:8.0.31 OS:Any
Assigned to: CPU Architecture:Any
Tags: Contribution

[25 Oct 2022 12:07] Yura Sorokin
Description:
Building MySQL Server 8.0.31 with the clang-15 toolset revealed a number of places with unused code, redundant constexpr definitions no longer needed in c++17, unqualified calls to 'std::move()', etc.

How to repeat:
mkdir ws
cd ws
git clone https://github.com/mysql/mysql-server.git
mkdir mysql-build
cd mysql-build
cmake ../mysql-server -DCMAKE_C_COMPILER=clang-15 -DCMAKE_CXX_COMPILER=clang++-15 ...
cmake --build . --parallel

Suggested fix:
Eliminate dead code discovered with clang-15 compiler

Fix "unqualified call to 'std::move'" warnings
('-Wunqualified-std-cast-call').

Along with that, remove 'using std::move' from the source files.

Fix "a function declaration without a prototype is deprecated in
all versions of C" warnings ('-Wstrict-prototypes') in 'libcbor'.

Fix problem with detecting 'std::is_trivially_copyable' presence
in 'robin-hood-hashing/robin_hood.h' when building with a 'clang'
family of compilers.

Remove dead code detected with new 'clang-15' optimizer
('-Wno-unused-but-set-variable').

Binaries compiled with 'clang-15' under Address Sanitizer
('-DWITH_ASAN=ON -DWITH_ASAN_SCOPE=ON') can no longer be run with
'thread_stack' set to '1M'. For this combination of
compiler / configuration options set the default value of
this system variable to '4M' 

Fix 'out-of-line definition of constexpr static
data member is redundant in C++17 and is deprecated' warnings by
removing these redundant definitions.

Because of that, remove 'base64.cc', 'content_type.cc',
'internet.cpp', and 'socket.cpp' from  the 'router' as they become
empty source files.

Convert 'harness_net_ts' target to header-only library as it
no longer has '.cc' files.

Rework 'json_schema_embedder': it no longer needs to generate an
empty '.cc' file (without 'constexpr' definition ) - an '.h' is now
everything that is needed. Because of this, the utility should expect
just 3 command line arguments '<in_file> <hdr_file> <symbol_name>'.
Update 'CMakeLists.txt' files invoking 'json_schema_embedder'
correspondingly.

Suppress '-Wno-unused-but-set-variable' warning in Bison-generated
files ('sql_yacc.cc', 'sql_hints.yy.cc', and 'fts/fts0pars.cc'). 

Due to partial support of DWARF-5 debug info format in Valgrind 3.18
(the latest out-of-the-box version available on supported platforms),
in order to run MySQL Server 8.0.31 under Valgrind it has to be
configured with the following CMake options
-DCMAKE_C_FLAGS_DEBUG=-gdwarf-4
-DCMAKE_CXX_FLAGS_DEBUG=-gdwarf-4
-DCMAKE_C_FLAGS_RELWITHDEBINFO="-O2 -gdwarf-4 -DNDEBUG"
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2 -gdwarf-4 -DNDEBUG"
Consider, including this logic into 'compiler_options.cmake'.
[25 Oct 2022 12:32] Yura Sorokin
Clang-15 patch for 8.0.31

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: clang_15_upstream_8_0_31.diff (application/octet-stream, text), 140.36 KiB.

[25 Oct 2022 13:34] MySQL Verification Team
Hello Yura Sorokin,

Thank you for the report and contribution.

regards,
Umesh
[25 Oct 2022 19:55] OCA Admin
Contribution submitted via Github - Bug #108870: Eliminated dead code discovered with clang-15 compiler 
(*) Contribution by Yura Sorokin (Github percona-ysorokin, mysql-server/pull/427#issuecomment-1290788321): I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: git_patch_1098847669.txt (text/plain), 149.45 KiB.

[7 Nov 2022 13:32] Ståle Deraas
Hi Yura,

This was already fixed in 8.0.32, but thanks anyway for your contributions. I have marked them as accepted.
[7 Nov 2022 13:34] Ståle Deraas
Duplicate of https://bugs.mysql.com/bug.php?id=108613