Skip to content
This repository has been archived by the owner on Jul 17, 2019. It is now read-only.

Return(x) should convert x to the desired type early #86

Closed
GoogleCodeExporter opened this issue Aug 24, 2015 · 1 comment
Closed

Return(x) should convert x to the desired type early #86

GoogleCodeExporter opened this issue Aug 24, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link
Contributor

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

@GoogleCodeExporter
Copy link
Contributor Author

Fixed in r235.

Original comment by vladlosev on 24 Nov 2009 at 12:07

  • Changed state: Fixed

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

No branches or pull requests

1 participant