Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compile source code error #4

Open
hnlyjjddll opened this issue Jul 15, 2020 · 1 comment
Open

compile source code error #4

hnlyjjddll opened this issue Jul 15, 2020 · 1 comment

Comments

@hnlyjjddll
Copy link

I download source code and change nothing. but compile error. the error log as follows:
hello_world.cpp:24:5: required from here
cpp11/impl.h:86:42: error: cannot bind non-const lvalue reference of type ‘testing::internal::MockSpec<int()>&’ to an rvalue of type ‘testing::internal::MockSpec<int()>’
return gmocker.With(p ...);

@eraser0
Copy link

eraser0 commented Sep 23, 2020

this is a bug which didn't reported by the older versions gcc, here is the patch to fix it

diff --git a/cpp11/impl.h b/cpp11/impl.h
index 7eddd48..f0b9dd7 100644
--- a/cpp11/impl.h
+++ b/cpp11/impl.h
@@ -80,7 +80,7 @@ namespace EasyMock
                 return gmocker.Invoke(p ...);
             }
 
-            ::testing::MockSpec<R(P...)>& gmock_EasyMockStubFunction(const ::testing::Matcher<P>&... p)
+            ::testing::MockSpec<R(P...)> gmock_EasyMockStubFunction(const ::testing::Matcher<P>&... p)
             {
                 gmocker.RegisterOwner(this);
                 return gmocker.With(p ...);

the gmocker.With(p ...) will create a local var, and a copy is necessary before return

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants