Skip to content

Commit 60482d8

Browse files
Elias Naurbradfitz
authored andcommitted
runtime: relax SetFinalizer documentation to allow &local
The SetFinalizer documentation states that "The argument obj must be a pointer to an object allocated by calling new or by taking the address of a composite literal." which precludes pointers to local variables. According to a comment on #6591, this case is expected to work. This CL updates the documentation for SetFinalizer accordingly. Fixes #6591 Change-Id: Id861b3436bc1c9521361ea2d51c1ce74a121c1af Reviewed-on: https://go-review.googlesource.com/29592 TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Austin Clements <[email protected]>
1 parent 413f1ef commit 60482d8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/runtime/mfinal.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,9 @@ func runfinq() {
226226
//
227227
// SetFinalizer(obj, nil) clears any finalizer associated with obj.
228228
//
229-
// The argument obj must be a pointer to an object allocated by
230-
// calling new or by taking the address of a composite literal.
229+
// The argument obj must be a pointer to an object allocated by calling
230+
// new, by taking the address of a composite literal, or by taking the
231+
// address of a local variable.
231232
// The argument finalizer must be a function that takes a single argument
232233
// to which obj's type can be assigned, and can have arbitrary ignored return
233234
// values. If either of these is not true, SetFinalizer aborts the

0 commit comments

Comments
 (0)