Source file
test/fixedbugs/issue41780.go
1
2
3
4
5
6
7
8
9 package main
10
11 type decimal struct {
12 d [8]byte
13 dp int
14 }
15
16 var powtab = []int{1, 3, 6, 9, 13, 16, 19, 23, 26}
17
18
19 func foo(d *decimal) int {
20 exp := int(d.d[1])
21 if d.dp < 0 || d.dp == 0 && d.d[0] < '5' {
22 var n int
23 if -d.dp >= len(powtab) {
24 n = 27
25 } else {
26 n = powtab[-d.dp]
27 }
28 exp += n
29 }
30 return exp
31 }
32
33 func main() {
34 var d decimal
35 d.d[0] = '1'
36 if foo(&d) != 1 {
37 println("FAILURE (though not the one this test was written to catch)")
38 }
39 }
40
View as plain text