You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the TestSliceIdentical test case, a and b are two different int slices with cap=0, len=0. However, the compiler or debugger might optimize this behavior, resulting in them having the same underlying memory. As mentioned, if a debugger is used, then this case will fail; similarly, simply adding fmt.Printf("%p %p\n", a, b) afterwards will also cause a failure. Therefore, I suggest modifying the implementation of sliceIdentical and its tests. Two slices of the same type with cap=0 should be considered equivalent slices (because appending to them will change the underlying memory, and the underlying memory of a cap=0 slice is meaningless).
This issue can be reproduced with Go version go1.22.2 darwin/amd64.
The text was updated successfully, but these errors were encountered:
In the
TestSliceIdentical
test case,a
andb
are two different int slices withcap=0, len=0
. However, the compiler or debugger might optimize this behavior, resulting in them having the same underlying memory. As mentioned, if a debugger is used, then this case will fail; similarly, simply addingfmt.Printf("%p %p\n", a, b)
afterwards will also cause a failure. Therefore, I suggest modifying the implementation of sliceIdentical and its tests. Two slices of the same type withcap=0
should be considered equivalent slices (because appending to them will change the underlying memory, and the underlying memory of acap=0
slice is meaningless).This issue can be reproduced with Go version go1.22.2 darwin/amd64.
The text was updated successfully, but these errors were encountered: