go/test/fixedbugs/issue21221.go
Matthew Dempsky fe77a5413e cmd/compile: fix constant pointer comparison failure
Previously, constant pointer-typed expressions could use either Mpint
or NilVal as their Val depending on their construction, but const.go
expects each type to have a single corresponding Val kind.

This CL changes pointer-typed expressions to exclusively use Mpint.

Fixes #21221.

Change-Id: I6ba36c9b11eb19a68306f0b296acb11a8c254c41
Reviewed-on: https://go-review.googlesource.com/105315
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2018-04-09 23:19:45 +00:00

19 lines
365 B
Go

// run
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import "unsafe"
func main() {
if unsafe.Pointer(uintptr(0)) != unsafe.Pointer(nil) {
panic("fail")
}
if (*int)(unsafe.Pointer(uintptr(0))) != (*int)(nil) {
panic("fail")
}
}