Source file
test/fixedbugs/issue59411.go
1
2
3
4
5
6
7 package main
8
9 import (
10 "math"
11 "reflect"
12 )
13
14 func main() {
15 for i := 0; i < 100; i++ {
16 f()
17 g()
18 }
19 }
20
21 func f() {
22
23 m := map[float64]int{}
24
25 const N = 13 << 4
26 for i := 0; i < N; i++ {
27 m[math.NaN()] = i
28 }
29
30 m[math.NaN()] = N
31
32
33 i := 0
34 for range m {
35 if i == 6 {
36
37 clear(m)
38 } else if i > 6 {
39
40 panic("BAD")
41 }
42 i++
43 }
44 if len(m) != 0 {
45 panic("clear did not empty the map")
46 }
47 }
48
49 func g() {
50
51 m := map[float64]int{}
52
53 const N = 13 << 4
54 for i := 0; i < N; i++ {
55 m[math.NaN()] = i
56 }
57
58 m[math.NaN()] = N
59
60
61 i := 0
62 v := reflect.ValueOf(m)
63 iter := v.MapRange()
64 for iter.Next() {
65 if i == 6 {
66
67 v.Clear()
68 } else if i > 6 {
69
70 panic("BAD")
71 }
72 i++
73 }
74 if v.Len() != 0 {
75 panic("clear did not empty the map")
76 }
77 }
78
View as plain text