eranpeer / FakeIt

C++ mocking made easy. A simple yet very expressive, headers only library for c++ mocking.
MIT License
1.22k stars 170 forks source link

There are deprecated warnings on OSX with C++20 and C++23 #320

Closed ClausKlein closed 2 months ago

ClausKlein commented 1 year ago
bash-3.2$ ninja clean
[0/1] Re-running CMake...
-- Building tests in C++23.
-- Sanitizers enabled: address, undefined.
-- Configuring done (0.1s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/clausklein/Workspace/cpp/FakeIt/build
[1/1] Cleaning all built files...
Cleaning... 29 files.
bash-3.2$ builddriver ninja
builddriver executing: 'ninja'
Compilation SUCCEED in 37.866091 seconds
Number of warnings: 9
WarningErrorEntry(path='/Users/clausklein/Workspace/cpp/FakeIt/tests/move_only_return_tests.cpp', lineno='66', severity='warning', message="ISO C++20 considers use of overloaded operator '==' (with operand types 'MoveOnlyReturnTests::ConcreteType' and 'MoveOnlyReturnTests::ConcreteType') to be ambiguous despite there being a unique best viable function [-Wambiguous-reversed-operator]", column='3')
WarningErrorEntry(path='/Users/clausklein/Workspace/cpp/FakeIt/tests/move_only_return_tests.cpp', lineno='84', severity='warning', message="ISO C++20 considers use of overloaded operator '==' (with operand types 'MoveOnlyReturnTests::ConcreteType' and 'MoveOnlyReturnTests::ConcreteType') to be ambiguous despite there being a unique best viable function [-Wambiguous-reversed-operator]", column='3')
WarningErrorEntry(path='/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/include/c++/v1/__memory/construct_at.h', lineno='63', severity='warning', message="destructor called on non-final 'MoveOnlyReturnTests::ConcreteType' that has virtual functions but non-virtual destructor [-Wdelete-non-abstract-non-virtual-dtor]", column='5')
WarningErrorEntry(path='/Users/clausklein/Workspace/cpp/FakeIt/tests/type_info_tests.cpp', lineno='36', severity='warning', message="expression with side effects will be evaluated despite being used as an operand to 'typeid' [-Wpotentially-evaluated-expression]", column='28')
WarningErrorEntry(path='/Users/clausklein/Workspace/cpp/FakeIt/tests/referece_types_tests.cpp', lineno='81', severity='warning', message="ISO C++20 considers use of overloaded operator '==' (with operand types 'ReferenceTypesTests::ConcreteType' and 'ReferenceTypesTests::ConcreteType') to be ambiguous despite there being a unique best viable function [-Wambiguous-reversed-operator]", column='3')
WarningErrorEntry(path='/Users/clausklein/Workspace/cpp/FakeIt/tests/referece_types_tests.cpp', lineno='105', severity='warning', message="ISO C++20 considers use of overloaded operator '==' (with operand types 'ReferenceTypesTests::ConcreteType' and 'ReferenceTypesTests::ConcreteType') to be ambiguous despite there being a unique best viable function [-Wambiguous-reversed-operator]", column='3')
WarningErrorEntry(path='/Users/clausklein/Workspace/cpp/FakeIt/tests/referece_types_tests.cpp', lineno='201', severity='warning', message="ISO C++20 considers use of overloaded operator '==' (with operand types 'ReferenceTypesTests::ConcreteType' and 'ReferenceTypesTests::ConcreteType') to be ambiguous despite there being a unique best viable function [-Wambiguous-reversed-operator]", column='3')
WarningErrorEntry(path='/Users/clausklein/Workspace/cpp/FakeIt/tests/remove_const_volatile_tests.cpp', lineno='85', severity='warning', message="volatile-qualified parameter type 'const volatile std::string' (aka 'const volatile basic_string<char, char_traits<char>, allocator<char>>') is deprecated [-Wdeprecated-volatile]", column='62')
WarningErrorEntry(path='/Users/clausklein/Workspace/cpp/FakeIt/tests/default_behaviore_tests.cpp', lineno='212', severity='warning', message="variable 'a' set but not used [-Wunused-but-set-variable]", column='8')
bash-3.2$ 

see https://github.com/eranpeer/FakeIt/pull/319 and https://github.com/ClausKlein/FakeIt/actions/runs/4805793677

ljden commented 1 year ago

The ISO C++20 considers use of overloaded operator '==' ... to be ambiguous despite there being a unique best viable function error comes from the mismatch in constness of the operator==() definition - see S.O. for more explanation https://stackoverflow.com/a/60387060/6946577 ie: https://github.com/eranpeer/FakeIt/blob/cb39d8a053876f74dfeed66dd335d3041f142095/tests/move_only_return_tests.cpp#L36 should be

-                bool operator==(const ConcreteType& other) {
+                bool operator==(const ConcreteType& other) const {
malcolmdavey commented 1 year ago

Feel free to make a pull request

FranckRJ commented 2 months ago

Since #322 and #329 are merged there shouldn't be any warning in the next version (with the default compiler options at least).