-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
Description
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version
)?
1.9.2 linux/amd64
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env
)?
linux/amd64
What did you do?
https://play.golang.org/p/xTqB19F6f5J
package main
import (
"fmt"
)
type T struct{}
func main() {
m := make(map[*T]bool)
for i := 0; i < 32; i++ {
m[new(T)] = false
}
fmt.Println(m)
}
What did you expect to see?
I expect to see a map with 32 distinct entries.
What did you see instead?
I see a map with a single entry.
Note that this behavior only occurs when T is struct{}, if you change it to e.g. bool you get 32 entries.
Also note that using a composite literal instead does not help.
I suspect this is an over-optimization issue.