abseil / abseil-cpp

Abseil Common Libraries (C++)
https://abseil.io
Apache License 2.0
14.69k stars 2.57k forks source link

[Bug]: Build error during cmake quick start #1722

Closed finco123 closed 1 month ago

finco123 commented 1 month ago

Describe the issue

Something related to variant causes error when building the CMake target tests based on quick start .

/home/abseil-cpp/build/googletest-src/googletest/include/gtest/internal/gtest-port.h:784:49: note: expanded from macro
      'GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED'
#define GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED [[maybe_unused]]
                                                ^
In file included from /home/abseil-cpp/absl/functional/overload_test.cc:24:
In file included from /home/abseil-cpp/absl/types/variant.h:50:
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/variant:157:13: error: cannot cast private base class 'std::__detail::__variant::_Variant_storage<false, int,
      double, std::__cxx11::basic_string<char> >' to 'std::variant<int, double, std::__cxx11::basic_string<char> >'
            return static_cast<variant<_Types...>&>(__rhs);
                   ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/variant:408:7: note: in instantiation of function template specialization 'std::__variant_cast<int, double,
      std::__cxx11::basic_string<char> , std::__detail::__variant::_Variant_storage<false, int, double, std::__cxx11::basic_string<char> > &>' requested here
          }, __variant_cast<_Types...>(*this));
             ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/variant:414:9: note: in instantiation of member function 'std::__detail::__variant::_Variant_storage<false,
      int, double, std::__cxx11::basic_string<char> >::_M_reset' requested here
      { _M_reset(); }
        ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/variant:506:20: note: in instantiation of member function 'std::__detail::__variant::_Variant_storage<false,
      int, double, std::__cxx11::basic_string<char> >::~_Variant_storage' requested here
      using _Base::_Base;
                   ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/variant:1288:7: note: constrained by private inheritance here
    : private __detail::__variant::_Variant_base<_Types...>,

Steps to reproduce the problem

  1. Follow the quick start.
  2. change C++=14 to C++17 with cmake -DABSL_BUILD_TESTING=ON -DABSL_USE_GOOGLETEST_HEAD=ON -DCMAKE_CXX_STANDARD=14 ..

What version of Abseil are you using?

20240116.2 Git output: d7aaad83b488fd62bd51c81ecf16cd938532cc0a

What operating system and version are you using?

Ubuntu 18.04.1

What compiler and version are you using?

gcc (Ubuntu 10.3.0-1ubuntu1\~18.04\~1) 10.3.0 clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)

What build system are you using?

cmake version 3.30.0

Additional context

I try to build with C++14, another error occurs.

/home/abseil-cpp/absl/strings/char_formatting_test.cc:47:37: error: conversion from '(anonymous namespace)::CharEnum' to 'const substitute_internal::Arg'
      is ambiguous
derekmauro commented 1 month ago

I can't reproduce this problem. Please note that GCC 10 is not the default compiler that comes with Ubuntu 18.04, so if you installed it yourself, it may be misconfigured. Full instructions would be required if you need help, but Ubuntu 18.04 is not a supported platform anymore, so it is not likely anyone will look into this.