tikv / rocksdb

A library that provides an embeddable, persistent key-value store for fast storage.
http://rocksdb.org
GNU General Public License v2.0
120 stars 93 forks source link

Cannot compile in g++ environment #352

Closed dust1 closed 1 year ago

dust1 commented 1 year ago

Expected behavior

compile fail in g++-13, If it is g++-12, it still can't compiled.

Actual behavior

compile fail

Steps to reproduce the behavior

gcc & g++ version

gcc (Debian 13.2.0-4) 13.2.0
g++ (Debian 13.2.0-4) 13.2.0
gcc (Debian 12.2.0-9) 12.2.0
g++ (Debian 12.2.0-9) 12.2.0

error log:

  CC       options/customizable_test.o
In file included from /usr/include/c++/13/functional:59,
                 from ./db/db_impl/db_impl.h:13,
                 from ./db/db_test_util.h:24,
                 from options/customizable_test.cc:17:
In copy constructor ‘std::function<_Res(_ArgTypes ...)>::function(const std::function<_Res(_ArgTypes ...)>&) [with _Res = rocksdb::Status; _ArgTypes = {const rocksdb::ConfigOptions&, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, void*}]’,
    inlined from ‘rocksdb::OptionTypeInfo::OptionTypeInfo(int, rocksdb::OptionType, rocksdb::OptionVerificationType, rocksdb::OptionTypeFlags, const rocksdb::ParseFunc&, const rocksdb::SerializeFunc&, const rocksdb::EqualsFunc&)’ at ./include/rocksdb/utilities/options_type.h:240:9,
    inlined from ‘static rocksdb::OptionTypeInfo rocksdb::OptionTypeInfo::AsCustomSharedPtr(int, rocksdb::OptionVerificationType, rocksdb::OptionTypeFlags, const rocksdb::SerializeFunc&, const rocksdb::EqualsFunc&) [with T = rocksdb::{anonymous}::TestCustomizable]’ at ./include/rocksdb/utilities/options_type.h:441:36,
    inlined from ‘static rocksdb::OptionTypeInfo rocksdb::OptionTypeInfo::AsCustomSharedPtr(int, rocksdb::OptionVerificationType, rocksdb::OptionTypeFlags) [with T = rocksdb::{anonymous}::TestCustomizable]’ at ./include/rocksdb/utilities/options_type.h:419:69:
/usr/include/c++/13/bits/std_function.h:391:17: error: ‘<anonymous>’ may be used uninitialized [-Werror=maybe-uninitialized]
  391 |             __x._M_manager(_M_functor, __x._M_functor, __clone_functor);
      |             ~~~~^~~~~~~~~~
/usr/include/c++/13/bits/std_function.h: In function ‘static rocksdb::OptionTypeInfo rocksdb::OptionTypeInfo::AsCustomSharedPtr(int, rocksdb::OptionVerificationType, rocksdb::OptionTypeFlags) [with T = rocksdb::{anonymous}::TestCustomizable]’:
/usr/include/c++/13/bits/std_function.h:267:7: note: by argument 2 of type ‘const std::_Any_data&’ to ‘static bool std::_Function_handler<_Res(_ArgTypes ...), _Functor>::_M_manager(std::_Any_data&, const std::_Any_data&, std::_Manager_operation) [with _Res = rocksdb::Status; _Functor = rocksdb::OptionTypeInfo::AsCustomSharedPtr<rocksdb::{anonymous}::TestCustomizable>(int, rocksdb::OptionVerificationType, rocksdb::OptionTypeFlags, const rocksdb::SerializeFunc&, const rocksdb::EqualsFunc&)::<lambda(const rocksdb::ConfigOptions&, const std::string&, const std::string&, void*)>; _ArgTypes = {const rocksdb::ConfigOptions&, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, void*}]’ declared here
  267 |       _M_manager(_Any_data& __dest, const _Any_data& __source,
      |       ^~~~~~~~~~
In file included from ./monitoring/statistics_impl.h:19,
                 from ./monitoring/statistics.h:10,
                 from ./monitoring/perf_step_timer.h:9,
                 from ./monitoring/perf_context_imp.h:7,
                 from ./util/user_comparator_wrapper.h:11,
                 from ./db/dbformat.h:22,
                 from ./db/memtable.h:20,
                 from ./db/memtable_list.h:16,
                 from ./db/column_family.h:17,
                 from ./db/db_impl/db_impl.h:22:
./include/rocksdb/utilities/options_type.h:428:12: note: ‘<anonymous>’ declared here
  428 |     return OptionTypeInfo(
      |            ^~~~~~~~~~~~~~~
  429 |         offset, OptionType::kCustomizable, ovt,
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  430 |         flags | OptionTypeFlags::kShared,
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  431 |         [](const ConfigOptions& opts, const std::string& name,
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  432 |            const std::string& value, void* addr) {
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  433 |           auto* shared = static_cast<std::shared_ptr<T>*>(addr);
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  434 |           if (name == kIdPropName() && value.empty()) {
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  435 |             shared->reset();
      |             ~~~~~~~~~~~~~~~~
  436 |             return Status::OK();
      |             ~~~~~~~~~~~~~~~~~~~~
  437 |           } else {
      |           ~~~~~~~~
  438 |             return T::CreateFromString(opts, value, shared);
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  439 |           }
      |           ~
  440 |         },
      |         ~~
  441 |         serialize_func, equals_func);
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
make: *** [Makefile:2466: options/customizable_test.o] Error 1
Connor1996 commented 1 year ago

looks like https://github.com/facebook/rocksdb/issues/9633 You can work around it

dust1 commented 1 year ago

After I use DISABLE_WARNING_AS_ERROR=1 can compile😀. Will this problem be solved in the future? ceresdb depends on it and cannot be compiled in a gcc-13 environment

Connor1996 commented 1 year ago

We have no enviorment for reproducing this, welcome to file a PR to fix it