Skip to content

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

@mdempsky

Description

@mdempsky

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions