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

Clang 14.0.6 compile error #302

Closed helmesjo closed 1 year ago

helmesjo commented 1 year ago

Hi! Just tried to compile using Clang 14.0.6 and it spewed some errors at me, so figured I'd share. Built with latest C++ standard flag.

WhenFunctor.hpp:86:20: error: no matching constructor for initialization of 'MethodProgress<int, int>'
            return progress;
                   ^~~~~~~~
../custom_testing_framework_tests.cpp:192:3: note: in instantiation of function template specialization 'fakeit::WhenFunctor::operator()<int, int>' requested here
                When(Method(mock,func)).Return(0);
                ^
../api_macros.hpp:41:9: note: expanded from macro 'When'
    When(call)
        ^
../WhenFunctor.hpp:58:13: note: candidate constructor not viable: expects an lvalue for 1st argument
            MethodProgress(MethodProgress &other) :
            ^
../WhenFunctor.hpp:62:13: note: candidate constructor not viable: no known conversion from 'MethodProgress<int, int>' to 'StubbingContext<int, int> &' for 1st argument
            MethodProgress(StubbingContext<R, arglist...> &xaction) :
            ^
FranckRJ commented 1 year ago

Could you provide the code that you are trying to compile that causes the issue? And which version of FakeIt did you use?

FranckRJ commented 1 year ago

Ok I reproduced the issue on the tests, just a missing "const" in the parameter of the copy constructor of MethodProgress, it's only an error since C++23 because it seems that now parameter of return statements are considered xvalue and not lvalue, or something like that.

Anyway, it will be fixed in the next release, thanks.

FranckRJ commented 1 year ago

Should be fixed by #303, the fix will be available in FakeIt 2.4.0.

helmesjo commented 1 year ago

Great, thanks! Any ETA?

FranckRJ commented 1 year ago

FakeIt 2.4.0 won't be released this year, an optimistic schedule would be first quarter of 2023 but I can't guarantee anything.

After thinking a bit more about it I think that this fix may deserve to be released earlier, in an hotfix (2.3.2). Because not being able to use the library with C++23 is pretty big, we're pretty close to the standardisation of the new version of the language. So I'll probably release an hotfix next week.

helmesjo commented 1 year ago

A hotfix would be swell, thanks!

FranckRJ commented 1 year ago

I released FakeIt 2.3.2 which contains the fix.