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

cmd/compile: missing panic on nil pointer-to-empty-struct dereference #23837

Closed
mdempsky opened this issue Feb 15, 2018 · 4 comments
Closed

cmd/compile: missing panic on nil pointer-to-empty-struct dereference #23837

mdempsky opened this issue Feb 15, 2018 · 4 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@mdempsky
Copy link
Member

I expect this program should panic, but it doesn't:

package main

func f(p, q *struct{}) bool {
        return *p == *q
}

func main() {
        f(nil, nil)
}

For comparison:

  1. Changing f to func f(p, q *struct{ f struct{} }) bool { return p.f == q.f } causes a panic. It appears "checknotnil" checks for both of these were added to walkexpr in d3c758d, but then the OIND case was removed as "redundant" in aa0439b.

  2. gccgo doesn't panic on either of these.

/cc @griesemer @ianlancetaylor

@ianlancetaylor ianlancetaylor added the NeedsFix The path to resolution is known, but the work has not been done. label Mar 28, 2018
@ianlancetaylor ianlancetaylor added this to the Go1.11 milestone Mar 28, 2018
@odeke-em
Copy link
Member

Nice catch @mdempsky, thanks!

@ianlancetaylor should we be opening an equivalent bug for gccgo?

@ianlancetaylor
Copy link
Contributor

@odeke-em No real need for a separate bug against gccgo, it should get fixed when the testsuite is updated if not earlier. This doesn't seem like a high priority matter. Thanks.

@odeke-em
Copy link
Member

@ianlancetaylor cool, thanks.

@gopherbot
Copy link

Change https://golang.org/cl/145757 mentions this issue: cmd/compile: when comparing 0-size types, make sure expr side-effects survive

@golang golang locked and limited conversation to collaborators Oct 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Projects
None yet
Development

No branches or pull requests

4 participants