Source file test/fixedbugs/bug364.go
1 // run 2 3 // Copyright 2011 The Go Authors. All rights reserved. 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file. 6 7 package main 8 9 import "fmt" 10 11 var s string 12 13 func accum(args ...interface{}) { 14 s += fmt.Sprintln(args...) 15 } 16 17 func f(){ 18 v := 0.0 19 for i := 0; i < 3; i++ { 20 v += 0.1 21 defer accum(v) 22 } 23 } 24 25 func main() { 26 f() 27 if s != "0.30000000000000004\n0.2\n0.1\n" { 28 println("BUG: defer") 29 print(s) 30 } 31 } 32