ned14 / outcome

Provides very lightweight outcome<T> and result<T> (non-Boost edition)
https://ned14.github.io/outcome
Other
704 stars 62 forks source link

Build fails with GCC 10 #267

Closed awvwgk closed 1 year ago

awvwgk commented 2 years ago

Build error

[  2%] Building CXX object CMakeFiles/outcome_hl--comparison.dir/test/tests/comparison.cpp.o
In file included from /home/conda/staged-recipes/build_artifacts/outcome-cpp_1657104035881/work/test/tests/../../include/outcome/config.hpp:35,
                 from /home/conda/staged-recipes/build_artifacts/outcome-cpp_1657104035881/work/test/tests/../../include/outcome/coroutine_support.hpp:28,
                 from /home/conda/staged-recipes/build_artifacts/outcome-cpp_1657104035881/work/test/tests/../../include/outcome.hpp:26,
                 from /home/conda/staged-recipes/build_artifacts/outcome-cpp_1657104035881/work/test/tests/comparison.cpp:29:
/home/conda/staged-recipes/build_artifacts/outcome-cpp_1657104035881/work/test/tests/../../include/outcome/basic_outcome.hpp: In instantiation of 'constexpr bool outcome_v2::operator==(const outcome_v2::basic_result<R, S, T>&, const outcome_v2::basic_outcome<R, S, P, N>&) [with T = int; U = std::error_code; V = outcome_v2::policy::error_code_throw_as_system_error<int, std::error_code, void>; R = int; S = std::error_code; P = std::__exception_ptr::exception_ptr; N = outcome_v2::policy::error_code_throw_as_system_error<int, std::error_code, std::__exception_ptr::exception_ptr>]':
/home/conda/staged-recipes/build_artifacts/outcome-cpp_1657104035881/work/test/tests/../../include/outcome/basic_outcome.hpp:1093:1:   recursively required from 'constexpr bool outcome_v2::operator==(const outcome_v2::basic_result<R, S, T>&, const outcome_v2::basic_outcome<R, S, P, N>&) [with T = int; U = std::error_code; V = outcome_v2::policy::error_code_throw_as_system_error<int, std::error_code, void>; R = int; S = std::error_code; P = std::__exception_ptr::exception_ptr; N = outcome_v2::policy::error_code_throw_as_system_error<int, std::error_code, std::__exception_ptr::exception_ptr>]'
/home/conda/staged-recipes/build_artifacts/outcome-cpp_1657104035881/work/test/tests/../../include/outcome/basic_outcome.hpp:1093:1:   required from 'constexpr bool outcome_v2::operator==(const outcome_v2::basic_result<R, S, T>&, const outcome_v2::basic_outcome<R, S, P, N>&) [with T = int; U = std::error_code; V = outcome_v2::policy::error_code_throw_as_system_error<int, std::error_code, void>; R = int; S = std::error_code; P = std::__exception_ptr::exception_ptr; N = outcome_v2::policy::error_code_throw_as_system_error<int, std::error_code, std::__exception_ptr::exception_ptr>]'
/home/conda/staged-recipes/build_artifacts/outcome-cpp_1657104035881/work/test/tests/comparison.cpp:87:5:   required from here
/home/conda/staged-recipes/build_artifacts/outcome-cpp_1657104035881/work/test/tests/../../include/outcome/basic_outcome.hpp:1093:72: fatal error: template instantiation depth exceeds maximum of 900 (use '-ftemplate-depth=' to increase the maximum)
 1093 | OUTCOME_TREQUIRES(OUTCOME_TEXPR(std::declval<basic_outcome<R, S, P, N>>() == std::declval<basic_result<T, U, V>>()))
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/home/conda/staged-recipes/build_artifacts/outcome-cpp_1657104035881/work/test/tests/../../include/outcome/basic_outcome.hpp:1093:1: note: in expansion of macro 'OUTCOME_TREQUIRES'
 1093 | OUTCOME_TREQUIRES(OUTCOME_TEXPR(std::declval<basic_outcome<R, S, P, N>>() == std::declval<basic_result<T, U, V>>()))
      | ^~~~~~~~~~~~~~~~~
/home/conda/staged-recipes/build_artifacts/outcome-cpp_1657104035881/work/test/tests/../../include/outcome/basic_outcome.hpp:1093:19: note: in expansion of macro 'OUTCOME_TEXPR'
 1093 | OUTCOME_TREQUIRES(OUTCOME_TEXPR(std::declval<basic_outcome<R, S, P, N>>() == std::declval<basic_result<T, U, V>>()))
      |                   ^~~~~~~~~~~~~
compilation terminated.

System info

     active environment : base
    active env location : /opt/conda
            shell level : 1
       user config file : /home/conda/.condarc
 populated config files : /opt/conda/.condarc
                          /home/conda/.condarc
          conda version : 4.13.0
    conda-build version : 3.21.9
         python version : 3.9.13.final.0
       virtual packages : __linux=5.13.0=0
                          __glibc=2.17=0
                          __unix=0=0
                          __archspec=1=x86_64
       base environment : /opt/conda  (writable)
      conda av data dir : /opt/conda/etc/conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : /home/conda/staged-recipes/build_artifacts/pkg_cache
                          /opt/conda/pkgs
       envs directories : /opt/conda/envs
                          /home/conda/.conda/envs
               platform : linux-64
             user-agent : conda/4.13.0 requests/2.28.1 CPython/3.9.13 Linux/5.13.0-1031-azure centos/7.9.2009 glibc/2.17
                UID:GID : 1001:1001
             netrc file : None
           offline mode : False

CMake configuration

-- Found Git: /opt/conda/bin/git (found version "2.37.0") 
-- The C compiler identification is GNU 10.3.0
-- The CXX compiler identification is GNU 10.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: $BUILD_PREFIX/bin/x86_64-conda-linux-gnu-cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: $BUILD_PREFIX/bin/x86_64-conda-linux-gnu-c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found PythonInterp: $BUILD_PREFIX/bin/python (found version "3.8.13") 
-- Using cached scan of project outcome headers ...
-- Using cached scan of project outcome tests ...
-- Performing Test COMPILER_HAS_UBSAN
-- Performing Test COMPILER_HAS_UBSAN - Success
-- Performing Test COMPILER_HAS_ASAN
-- Performing Test COMPILER_HAS_ASAN - Success
-- Performing Test COMPILER_HAS_MSAN
-- Performing Test COMPILER_HAS_MSAN - Failed
-- Performing Test COMPILER_HAS_TSAN
-- Performing Test COMPILER_HAS_TSAN - Success
-- Performing Test COMPILER_HAS_SAFESTACK
-- Performing Test COMPILER_HAS_SAFESTACK - Failed
-- Performing Test COMPILER_HAS_STACK_PROTECTOR
-- Performing Test COMPILER_HAS_STACK_PROTECTOR - Success
-- Performing Test CXX_HAS_CONCEPTS_BY_DEFAULT
-- Performing Test CXX_HAS_CONCEPTS_BY_DEFAULT - Failed
-- Performing Test CXX_HAS_CONCEPTS_CLANG_GCC
-- Performing Test CXX_HAS_CONCEPTS_CLANG_GCC - Success
-- Performing Test CXX_HAS_COROUTINES_BY_DEFAULT
-- Performing Test CXX_HAS_COROUTINES_BY_DEFAULT - Failed
-- Performing Test CXX_HAS_COROUTINES_WITH_FLAG
-- Performing Test CXX_HAS_COROUTINES_WITH_FLAG - Success
-- Performing Test CXX_HAS_COROUTINES_WITH_FLAG_TS
-- Performing Test CXX_HAS_COROUTINES_WITH_FLAG_TS - Failed
-- NOTE: This compiler claims to support C++ 20, enabling for unit test suite
-- Configuring done
-- Generating done
-- Build files have been written to: $SRC_DIR/_build
ned14 commented 2 years ago

From the source code:

// C++ 20 operator== rewriting should take care of this for us, indeed // if we don't disable it, we cause Concept recursion to infinity!

if __cplusplus < 202000L && !_HAS_CXX20

Ergo, Conda is not setting __cplusplus to the right value for C++ 20, and that is the source of your problems.

awvwgk commented 2 years ago

Thanks for the hint. The conda recipe for outcome is currently staged at https://github.com/conda-forge/staged-recipes/pull/19502 and I've been running out of ideas what is going wrong with the build and conda-forge compilers.

kkraus14 commented 2 years ago

Workaround that fixed the issue locally for me was adding -DUNIT_TESTS_CXX_VERSION=17 to force the unit tests to use C++17 instead of C++20.

BurningEnlightenment commented 1 year ago

Since this hasn't seen any activity in a while, I'm going ahead and close this. Feel free to reopen if further qualifying information comes up (e.g. a reprex).