Closed
Description
The Go spec says that when using range over a map, the iteration order is not specified. With our current implementation, the iteration order is always consistent for maps with 8 or fewer elements. This is not wrong, but it means that when people write tests that use small maps, they sometimes do not notice that they are depending on a consistent iteration order. That dependency fails when they run the tests with gccgo, which uses a different map implementation. My suggestion is that we change the map code so that when iterating over a bucket it randomly goes either up or down. That will cause a different iteration order even for small maps, and thus make tests more reliable, with no real expense in runtime.