Skip to content

[Bug]: GTEST_INTERNAL_HAS_COMPARE_LIB has a wrong condition for older Android NDK releases #4933

@jpboivin

Description

@jpboivin

Describe the issue

GTEST_INTERNAL_HAS_COMPARE_LIB is checking for __cpp_lib_three_way_comparison (okay) and GTEST_INTERNAL_HAS_INCLUDE(<compare>) && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201907L. I think the later is trying to support early implementations of the three-way comparison, but it will fail on some (like the one that shipped with the Android NDK 24/25 release). That version of the NDK lacks the comparison operators needed by PrintTo. As it is a C++20 feature, I think it should only check for __cpp_lib_three_way_comparison (the feature test macro).

Here is the error:

02:10:02          In file included from D:\b\0\237187\externals\googletest\googletest\src\gtest-all.cc:38:
02:10:02          In file included from D:\b\0\237187\externals\googletest\googletest\include\gtest/gtest.h:74:
02:10:02          In file included from D:\b\0\237187\externals\googletest\googletest\include\gtest/gtest-death-test.h:43:
02:10:02          In file included from D:\b\0\237187\externals\googletest\googletest\include\gtest/internal/gtest-death-test-internal.h:47:
02:10:02          In file included from D:\b\0\237187\externals\googletest\googletest\include\gtest/gtest-matchers.h:49:
02:10:02 19>19>D:\b\0\237187\externals\googletest\googletest\include\gtest/gtest-printers.h(796,16): error : invalid operands to binary expression ('std::weak_ordering' and 'const std::weak_ordering') 
02:10:02            if (ordering == T::less) {
02:10:02                ~~~~~~~~ ^  ~~~~~~~
02:10:02          D:\b\0\237187\externals\googletest\googletest\include\gtest/gtest-printers.h(824,3): note: in instantiation of function template specialization 'testing::internal::PrintOrderingHelper<std::weak_ordering>' requested here
02:10:02            PrintOrderingHelper(ordering, os);

Steps to reproduce the problem

Build googletest (i.e. the gtest-all.cc file) with Android NDK 24 using C++20.

What version of GoogleTest are you using?

1.17.0

What operating system and version are you using?

Android NDK 24

What compiler and version are you using?

Clang 14 (the one from Android NDK 24)

What build system are you using?

CMake

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions