1
0
mirror of https://github.com/golang/go synced 2024-11-24 06:10:05 -07:00

5g: defer vs optimizer bug

Fixes #1924.

R=ken2
CC=golang-dev
https://golang.org/cl/4802063
This commit is contained in:
Russ Cox 2011-07-28 16:28:23 -04:00
parent 3de6228aea
commit 8c23c1ab87
2 changed files with 32 additions and 1 deletions

View File

@ -728,13 +728,19 @@ addsplits(void)
void
addmove(Reg *r, int bn, int rn, int f)
{
Prog *p, *p1;
Prog *p, *p1, *p2;
Adr *a;
Var *v;
p1 = mal(sizeof(*p1));
*p1 = zprog;
p = r->prog;
// If there's a stack fixup coming (after BL newproc or BL deferproc),
// delay the load until after the fixup.
p2 = p->link;
if(p2 && p2->as == AMOVW && p2->from.type == D_CONST && p2->from.reg == REGSP && p2->to.reg == REGSP && p2->to.type == D_REG)
p = p2;
p1->link = p->link;
p->link = p1;

25
test/fixedbugs/bug364.go Normal file
View File

@ -0,0 +1,25 @@
package main
import "fmt"
var s string
func accum(args ...interface{}) {
s += fmt.Sprintln(args...)
}
func f(){
v := 0.0
for i := 0; i < 3; i++ {
v += 0.1
defer accum(v)
}
}
func main() {
f()
if s != "0.30000000000000004\n0.2\n0.1\n" {
println("BUG: defer")
print(s)
}
}