vegetablemao / googlemock

Automatically exported from code.google.com/p/googlemock

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MatchAndExplainImpl fails to compile with VC++ 2013 /analyze

GoogleCodeExporter opened this issue · comments

When building all of Chrome with /analyze (static analysis) a build failure 
happened starting when this change was submitted:

https://codereview.chromium.org/777033004

This happened because this triggered problematic use of MatchAndExplainImpl 
with the compiler complaining:

error C2248: 'scoped_ptr<std::string,base::DefaultDeleter<T>>::scoped_ptr' : 
cannot access private member declared in class 
'scoped_ptr<std::string,base::DefaultDeleter<T>>'

This is presumably a compiler bug, but the workaround is so easy that it seems 
worth adding. This line, from gmock-matchers.h:

RefToConstProperty result = (obj.*property_)();

needs to be replaced with this:

RefToConstProperty result = std::move((obj.*property_)());

This makes the use of the move constructor with scoped_ptr explicit instead of 
implicit, and should have no effect on other code.

Here is the build failure:

http://build.chromium.org/p/chromium.fyi/builders/Chromium%20Windows%20Analyze/b
uilds/61/steps/compile/logs/stdio

Original issue reported on code.google.com by brucedaw...@chromium.org on 28 Jan 2015 at 11:18

This is currently the only issue preventing all of Chrome from building with 
/analyze.

Original comment by brucedaw...@chromium.org on 29 Jan 2015 at 12:04