Track pointer comparisons
- Dominant language
- Go
- Stars
- 1
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
Pointer comparisons are another important way in which a reference to a range-loop variable can be misused. It's _possible_ for Go code to compare two pointers using `==` or `!=`. Although this may not be a very commonly used feature, _someone_ might be using it, so we should check -- it will be interesting to see what we find.
For instance, the below loop will have different semantics after the change. We need to report anywhere we find it.
```
func main() {
var y int
for _, x := range []int{1,2,3,4} {
bar(&x, &y)
}
}
func bar(x, y *int) {
if x == y {
fmt.Printf("memory address %p found before %p", x, y)
}
}
```
Contributor guide
Research direction
Start by locating the existing analysis for references to range-loop variables in this repository. Extend the reported cases to include comparisons using == and !=, using the example in the issue as a behavioral guide, then run the relevant existing analysis checks to confirm such comparisons are reported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100