Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestSliceIdentical Fails When Debugger is Attached #1272

Closed
RiversJin opened this issue Apr 8, 2024 · 0 comments
Closed

TestSliceIdentical Fails When Debugger is Attached #1272

RiversJin opened this issue Apr 8, 2024 · 0 comments

Comments

@RiversJin
Copy link

RiversJin commented Apr 8, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant