When Return(x) is used in an action that returns type T, where x has type
U, x is not converted to type T until the action is actually performed.
This has two problems:
1. the U => T conversion is done _every_ time the action is performed; in
general it's more efficient to do the conversion only once.
2. if the conversion depends on values that go out of scope after the
EXPECT_CALL() finishes, it won't work. e.g.
// Bar() returns type T. Foo(v) returns type U. Conversion from
// Foo(v) to U requires v to be alive.
EXPECT_CALL(mock, Bar()).WillRepeatedly(Return(Foo(v)));
... v goes out of scope here ...
mock.Bar(); // Crash!
I give this a high priority, as the later we fix this, the harder it gets
(as it's more likely the change will break existing clients).
Original issue reported on code.google.com by zhanyong...@gmail.com on 3 Nov 2009 at 12:45
Original issue reported on code.google.com by
zhanyong...@gmail.com
on 3 Nov 2009 at 12:45