You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In stdlibc++ in GCC 15, stricter requirements have been imposed on std::expected’s operator== to comply with C++ standard requirements. This, unfortunately, causes compilation problems when using MOCK_METHOD on a method with return type std::expected<T, U> (except if T is void). I linked to a complete example on Compiler Explorer below.
When considering if std::expected::operator== (3) is usable, the compiler concludes that there is a circular dependency and fails on a static assertion instead of concluding that variant (3) is not usable and moving on to the next candidate. It is likely a bug in GCC/libstdc++, but it is not scheduled to be fixed until GCC 15.2.
The line of code in Google Test that triggers this is line 785 in gmock-actions.h:
where fun_ is a std::function<F>. If F is a function signature that returns std::expected, the mentioned std::expected::operator== variant is somehow considered by the compiler (I do not exactly why that is), and again compilation fails as soon as GCC 15 evaluates its constraints.
Even though the current definition is perfectly legal C++ and standard compliant, I propose a slight modification to the definition of IsDoDefault():
boolIsDoDefault() const { return !fun_; }
It is functionally equivalent and equally valid C++, but also works with GCC 15.
Describe the issue
In stdlibc++ in GCC 15, stricter requirements have been imposed on
std::expected
’soperator==
to comply with C++ standard requirements. This, unfortunately, causes compilation problems when usingMOCK_METHOD
on a method with return typestd::expected<T, U>
(except ifT
isvoid
). I linked to a complete example on Compiler Explorer below.When considering if std::expected::operator== (3) is usable, the compiler concludes that there is a circular dependency and fails on a static assertion instead of concluding that variant
(3)
is not usable and moving on to the next candidate. It is likely a bug in GCC/libstdc++, but it is not scheduled to be fixed until GCC 15.2.The line of code in Google Test that triggers this is line 785 in gmock-actions.h:
where
fun_
is astd::function<F>
. IfF
is a function signature that returnsstd::expected
, the mentionedstd::expected::operator==
variant is somehow considered by the compiler (I do not exactly why that is), and again compilation fails as soon as GCC 15 evaluates its constraints.Even though the current definition is perfectly legal C++ and standard compliant, I propose a slight modification to the definition of
IsDoDefault()
:It is functionally equivalent and equally valid C++, but also works with GCC 15.
Steps to reproduce the problem
Complete minimal example:
https://godbolt.org/z/dTY65Y4v4
What version of GoogleTest are you using?
main
What operating system and version are you using?
RockyLinux 9.5
What compiler and version are you using?
GCC 15.1.0
What build system are you using?
CMake 3.31
Additional context
No response
The text was updated successfully, but these errors were encountered: