summaryrefslogtreecommitdiff
path: root/test/fixedbugs/bug450.go
blob: af27b723659b1fb198d23d256fb6fb740e2b72dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// run

// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Issue 3899: 8g incorrectly thinks a variable is
// "set but not used" and elides an assignment, causing
// variables to end up with wrong data.
//
// The reason is a miscalculation of variable width.

package main

func bar(f func()) {
	f()
}

func foo() {
	f := func() {}
	if f == nil {
	}
	bar(f)
}

func main() {
	foo()
}