-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
returning readonly reference #8
Comments
This should be: public static Length# Create(double value, LengthUnit unit) {
Length# length = new Length();
length.Set(value, unit);
return length;
} Diagnostics need to be improved - assigning a new object to a non-shared pointer is obviously a leak. |
Error added - it catches cases such as: Length p = new Length();
Length Create() { return new Length(); }
void Foo(Length length) { } ... Foo(new Length); with the message:
|
Thanks! Yeah I understand |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've got this method (want to use an immutable object pattern, not concerned about max performance):
I think this output C++ code leaks memory? I'm not an expert in C++ but I don't see a way that the shared pointer could be released:
The text was updated successfully, but these errors were encountered: