achen7 / googlemock

Automatically exported from code.google.com/p/googlemock
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

MatchAndExplainImpl fails to compile with VC++ 2013 /analyze #172

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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