[tools] go/ssa: make Const(unsafe.Pointer, nil).IsNil() true

1 view
Skip to first unread message

Alan Donovan (Gerrit)

unread,
Jun 26, 2026, 4:57:33 PM (14 hours ago) Jun 26
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Alan Donovan has uploaded the change for review

Commit message

go/ssa: make Const(unsafe.Pointer, nil).IsNil() true

Fixes golang/go#80121
Change-Id: I958f2849334eb5988e0e530a796fcd61559fb81d

Change diff

diff --git a/go/ssa/const.go b/go/ssa/const.go
index 91ed6f2..73a8213 100644
--- a/go/ssa/const.go
+++ b/go/ssa/const.go
@@ -131,7 +131,9 @@
return u != nil && nillable(u)
})
}
- switch t.Underlying().(type) {
+ switch t := t.Underlying().(type) {
+ case *types.Basic:
+ return t.Kind() == types.UnsafePointer
case *types.Pointer, *types.Slice, *types.Chan, *types.Map, *types.Signature:
return true
case *types.Interface:
diff --git a/go/ssa/const_test.go b/go/ssa/const_test.go
index 6097bd9..ec067a8 100644
--- a/go/ssa/const_test.go
+++ b/go/ssa/const_test.go
@@ -97,3 +97,10 @@
t.Errorf("ssa.NewConst(%v, %s).String() = %v, want %v", nil, tup, got, want)
}
}
+
+func TestConstUnsafePointerNil(t *testing.T) {
+ c := ssa.NewConst(nil, types.Typ[types.UnsafePointer])
+ if !c.IsNil() {
+ t.Errorf("Const(unsafe.Pointer(nil)).IsNil() = false")
+ }
+}

Change information

Files:
  • M go/ssa/const.go
  • M go/ssa/const_test.go
Change size: S
Delta: 2 files changed, 10 insertions(+), 1 deletion(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: I958f2849334eb5988e0e530a796fcd61559fb81d
Gerrit-Change-Number: 794881
Gerrit-PatchSet: 1
Gerrit-Owner: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Alan Donovan (Gerrit)

unread,
Jun 26, 2026, 4:57:50 PM (14 hours ago) Jun 26
to goph...@pubsubhelper.golang.org, Mark Freeman, Dominik Honnef, golang...@luci-project-accounts.iam.gserviceaccount.com, golang-co...@googlegroups.com
Attention needed from Mark Freeman

Alan Donovan voted Auto-Submit+1

Auto-Submit+1
Open in Gerrit

Related details

Attention is currently required from:
  • Mark Freeman
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: I958f2849334eb5988e0e530a796fcd61559fb81d
Gerrit-Change-Number: 794881
Gerrit-PatchSet: 1
Gerrit-Owner: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Mark Freeman <markf...@google.com>
Gerrit-CC: Dominik Honnef <dom...@honnef.co>
Gerrit-Attention: Mark Freeman <markf...@google.com>
Gerrit-Comment-Date: Fri, 26 Jun 2026 20:57:47 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages