Closed GoogleCodeExporter closed 9 years ago
Google Mock code is correct here.
Warning C4373 is a compatibility warnings. Older versions of VC++ did not
comply with the standard. The new version is compliant, but the behavior of C++
programs written originally to the older versions may have changed. This
warning helps you find out when that happens. But if you don't have that
warning occurringe elsewhere in your code, simply disable it. Google C4373 for
more information.
Original comment by vladlosev
on 19 May 2011 at 5:13
According the documentation this warning happens when the signitures differ.
struct Base
{
virtual void f(int i) {
printf("base\n");
}
};
struct Derived : Base
{
void f(const int i) { // C4373
printf("derived\n");
}
};
The question it then: why is google mock creating methods with a different
signature (i.e. dropping the const) in this case - given the signature in the
base class and the value given to the MOCK_MACRO are the same.
C4373 shouldn't happen if signatures are the same - but google mock is causing
this in the case.
This still looks like a bug in google mock.
MOCK_METHOD1(Func, void(const int));
is generating
void Func(int), not void Func(const int)
Original comment by malcolm....@str.com.au
on 20 May 2011 at 1:45
The MOCK_METHOD macros operate on function types, and C++ considers types T(U)
and T(const U) equivalent unless U is a reference type.
Original comment by vladlosev
on 20 May 2011 at 2:13
Is then a flaw with C++, especially C++ type forwarding (or similar)?
Original comment by malcolm....@str.com.au
on 20 May 2011 at 2:54
There is no flaw. The const parameter makes sense only inside the function. It
doesn't matter for the caller and is thus not part of the function's type.
Original comment by vladlosev
on 20 May 2011 at 6:32
Original issue reported on code.google.com by
yere...@gmail.com
on 19 May 2011 at 2:27