You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
func foo(x int) (y int) {
p := &x
q := &y
*q = *p
return
}
compile with "go tool 6g -S foo.go"
The assembly is
0005 MOVQ $0,y+8(FP)
0006 LEAQ x+0(FP),BX
0007 MOVQ BX,CX
0008 LEAQ y+8(FP),BX
0009 CMPQ BX,$0
0010 JNE $1,12
0011 MOVL AX,(BX)
0012 NOP ,
0013 MOVQ (CX),R8
0014 MOVQ R8,(BX)
0015 RET ,
There is a nil check (CMPQ/JNE/MOVL/NOP) on the address of the return value, a value
that certainly non-nil.
Note that there is no nil check on the address of the argument.
The text was updated successfully, but these errors were encountered:
rsc
changed the title
cmd/gc: unnecessary nil checks on address of return values
cmd/compile: unnecessary nil checks on address of return values
Jun 8, 2015
The text was updated successfully, but these errors were encountered: