USCiLab / cereal

A C++11 library for serialization
BSD 3-Clause "New" or "Revised" License
4.18k stars 751 forks source link

clang-tidy error: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign,-warnings-as-errors] #660

Open ClausKlein opened 3 years ago

ClausKlein commented 3 years ago
# ...
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
3 warnings treated as errors
egrep '\b(warning|error):' .run-clang-tidy.log | perl -pe 's/(^.*) (warning|error):/\2/' | sort -u
error 4 uninitialized fields at the end of the constructor call [clang-analyzer-optin.cplusplus.UninitializedObject,-warnings-as-errors]
error 6 uninitialized fields at the end of the constructor call [clang-analyzer-optin.cplusplus.UninitializedObject,-warnings-as-errors]
error Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign,-warnings-as-errors]
error The expression is an uninitialized value. The computed value will also be garbage [clang-analyzer-core.uninitialized.Assign,-warnings-as-errors]
warning do not define a C-style variadic function; consider using a function parameter pack or currying instead [cert-dcl50-cpp]
warning do not use unnamed namespaces in header files [cert-dcl59-cpp]
warning expression is redundant [misc-redundant-expression]
warning function 'ParseArray<272, rapidjson::BasicIStreamWrapper<std::__1::basic_istream<char>>, rapidjson::GenericDocument<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>, rapidjson::CrtAllocator>>' is within a recursive call chain [misc-no-recursion]
warning function 'ParseObject<272, rapidjson::BasicIStreamWrapper<std::__1::basic_istream<char>>, rapidjson::GenericDocument<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>, rapidjson::CrtAllocator>>' is within a recursive call chain [misc-no-recursion]
warning function 'ParseValue<272, rapidjson::BasicIStreamWrapper<std::__1::basic_istream<char>>, rapidjson::GenericDocument<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>, rapidjson::CrtAllocator>>' is within a recursive call chain [misc-no-recursion]
warning function 'parse_element<1057>' is within a recursive call chain [misc-no-recursion]
warning function 'parse_node<1057>' is within a recursive call chain [misc-no-recursion]
warning function 'parse_node_contents<1057>' is within a recursive call chain [misc-no-recursion]
warning function 'print_children<std::__1::ostream_iterator<char, char, std::__1::char_traits<char>>, char>' is within a recursive call chain [misc-no-recursion]
warning function 'print_element_node<std::__1::ostream_iterator<char, char, std::__1::char_traits<char>>, char>' is within a recursive call chain [misc-no-recursion]
warning function 'print_node<std::__1::ostream_iterator<char, char, std::__1::char_traits<char>>, char>' is within a recursive call chain [misc-no-recursion]
warning function '~GenericValue' is within a recursive call chain [misc-no-recursion]
warning inclusion of deprecated C++ header 'inttypes.h'; consider using 'cinttypes' instead [modernize-deprecated-headers]
warning inclusion of deprecated C++ header 'stdint.h'; consider using 'cstdint' instead [modernize-deprecated-headers]
warning move assignment operators should be marked noexcept [performance-noexcept-move-constructor]
warning move constructors should be marked noexcept [performance-noexcept-move-constructor]
warning operator=() does not handle self-assignment properly [cert-oop54-cpp]
warning operator=() should always return '*this' [misc-unconventional-assign-operator]
warning operator=() should return 'GenericMemberIterator&' [misc-unconventional-assign-operator]
warning operator=() should return 'GenericValue&' [misc-unconventional-assign-operator]
warning operator=() should take 'GenericValue const&', 'GenericValue&&' or 'GenericValue' [misc-unconventional-assign-operator]
warning overloaded 'operator++' returns a non-constant object instead of a constant object type [cert-dcl21-cpp]
warning overloaded 'operator--' returns a non-constant object instead of a constant object type [cert-dcl21-cpp]
warning parameter 'enableSharedFunc' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param]
warning parameter 'ptr' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param]
warning pass by value and use std::move [modernize-pass-by-value]
warning std::move of the variable 'key' of the trivially-copyable type 'std::__1::type_index' has no effect; remove std::move() [performance-move-const-arg]
warning the parameter 'mangledName' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
warning use range-based for loop instead [modernize-loop-convert]
warning variable 'b' defined in a header file; variable definitions in header files can lead to ODR violations [misc-definitions-in-headers]
warning variable 'version' defined in a header file; variable definitions in header files can lead to ODR violations [misc-definitions-in-headers]
builddriver cat .run-clang-tidy.log 2>&1 > builddriver.log
builddriver executing: 'cat .run-clang-tidy.log'
Compilation SUCCEED in 0.015854 seconds
Number of warnings: 41
Number of errors: 6
Last Error:
  Message: "6 uninitialized fields at the end of the constructor call [clang-analyzer-optin.cplusplus.UninitializedObject,-warnings-as-errors]"
  Path: /Users/clausklein/Workspace/cpp/cereal/include/cereal/external/rapidxml/rapidxml.hpp
  Line Number: 917
  Column: 33
Claus-iMac:cereal clausklein$ 
ClausKlein commented 3 years ago

the sandbox source tree was checked with this clang-tidy config file:

https://github.com/ClausKlein/cereal/blob/develop/.clang-tidy

Claus-iMac:cereal clausklein$ make -n run-clang-tidy
mkdir -p ../.build-cereal-Debug
cd ../.build-cereal-Debug && cmake -G Ninja -Wdeprecated -Wdev \
      -DUSE_LCOV=OFF -DCMAKE_BUILD_TYPE=Debug \
      -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH \
      -DCMAKE_PREFIX_PATH="/usr/local;/usr/local;/usr/local/opt/boost;/opt/local;/usr" \
      -DCMAKE_STAGING_PREFIX=/usr/local \
      -DCMAKE_PROJECT_INCLUDE_BEFORE=/Users/clausklein/Workspace/cmake/before_project_setup.cmake \
      -DCMAKE_PROJECT_INCLUDE=/Users/clausklein/Workspace/cmake/build_options.cmake \
      -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_C_COMPILER=cc -DCMAKE_CXX_COMPILER=c++ /Users/clausklein/Workspace/cpp/cereal
ln -sf ../.build-cereal-Debug/compile_commands.json .
run-clang-tidy -header-filter='/Users/clausklein/Workspace/cpp/cereal/.*' -checks='-*non-private-member-*' sandbox 2>&1 | tee .run-clang-tidy.log
egrep '\b(warning|error):' .run-clang-tidy.log | perl -pe 's/(^.*) (warning|error):/\2/' | sort -u
builddriver cat .run-clang-tidy.log 2>&1 > builddriver.log
Claus-iMac:cereal clausklein$