Skip to content
New issue

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

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

Already on GitHub? # to your account

false-positive with int pointer dereference #12

Closed
ldez opened this issue Feb 20, 2021 · 0 comments · Fixed by #13
Closed

false-positive with int pointer dereference #12

ldez opened this issue Feb 20, 2021 · 0 comments · Fixed by #13

Comments

@ldez
Copy link
Contributor

ldez commented Feb 20, 2021

type myStruct struct {
	fieldC *int
}

func bug() {
	ms := myStruct{fieldC: func(v int) *int { return &v }(10)}

	_ = time.Duration(*somePointerDurationMillis()) * time.Millisecond

	_ = time.Millisecond * time.Duration(*somePointerDurationMillis())

	_ = time.Duration(*ms.fieldC) * time.Second

	_ = time.Second * time.Duration(*ms.fieldC)
}

func somePointerDurationMillis() *int {
	v := 10
	return &v
}
Multiplication of durations: `time.Duration(*somePointerDurationMillis()) * time.Millisecond`
Multiplication of durations: `time.Millisecond * time.Duration(*somePointerDurationMillis())`
Multiplication of durations: `time.Duration(*ms.fieldC) * time.Second`
Multiplication of durations: `time.Second * time.Duration(*ms.fieldC)`
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant