Skip to content
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

runtime: SetFinalizer may be called on local objects, contra doc #6591

Closed
adonovan opened this issue Oct 15, 2013 · 5 comments
Closed

runtime: SetFinalizer may be called on local objects, contra doc #6591

adonovan opened this issue Oct 15, 2013 · 5 comments

Comments

@adonovan
Copy link
Member

Fro http://golang.org/pkg/runtime/#SetFinalizer:
"The argument x must be a pointer to an object allocated by calling new or by
taking the address of a composite literal. The argument f must be a function that takes
a single argument of x's type and can have arbitrary ignored return values. If either of
these is not true, SetFinalizer aborts the program."

SetFinalizer does not, in fact, abort the program if the argument x is a the address of
a local object.  I think the spec wording needs to be updated to reflect this.

http://play.golang.org/p/v8810GsAzF
@ianlancetaylor
Copy link
Contributor

Comment 1:

I wouldn't call this the spec--we usually use that word for the language spec.  This is
just the documentation.
It is of course unsurprising that SetFinalizer works if you take the address of a local
variable.  I agree that the docs should be updated though I think the update can be a
minor one.

Labels changed: added priority-later, documentation, removed priority-triage.

@rsc
Copy link
Contributor

rsc commented Nov 27, 2013

Comment 2:

Labels changed: added go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 3:

Labels changed: added release-none, removed go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 4:

Labels changed: added repo-main.

@gopherbot
Copy link

CL https://golang.org/cl/29592 mentions this issue.

@golang golang locked and limited conversation to collaborators Sep 27, 2017
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

4 participants