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

Comments

Projects
None yet
4 participants
@mdempsky
Copy link
Member

commented Feb 15, 2018

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 this to the Go1.11 milestone Mar 28, 2018

@odeke-em

This comment has been minimized.

Copy link
Member

commented Apr 24, 2018

Nice catch @mdempsky, thanks!

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

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Apr 25, 2018

@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

This comment has been minimized.

Copy link
Member

commented Apr 25, 2018

@ianlancetaylor cool, thanks.

@gopherbot

This comment has been minimized.

Copy link

commented Oct 30, 2018

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

@gopherbot gopherbot closed this in f14067f Oct 30, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.