Skip to content

Make lifetime extension explicit #156

@BenFrantzDale

Description

@BenFrantzDale

Thanks for creating such a cool tool!

It would be great if lifetime extension were made explicit. That is, the GOTW#88 const& behavior: https://herbsutter.com/2008/01/01/gotw-88-a-candidate-for-the-most-important-const/

as in

struct C { virtual int get() const { return 0; } };
struct D : C { virtual int get() const override { return 1; } };

int foo() {
	const C& c = D();
  	return c.get();
}

Right now the above produces

...
int foo()
{
  const C & c = static_cast<const C&>(D());
  return c.get();
}

which is correct, but the insight I'd like to see would show that after the return, c is destroyed with D::~D().

I'm not sure how you'd show that in the output, though... Maybe in a comment?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requeststaleNo activity

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions