[go] cmd/compile/internal/staticinit: fix bug in global new(expr)

1 view
Skip to first unread message

Alan Donovan (Gerrit)

unread,
Jan 20, 2026, 4:48:44 PM (2 days ago) Jan 20
to goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Keith Randall, Keith Randall, Go LUCI, golang-co...@googlegroups.com

Alan Donovan submitted the change

Change information

Commit message:
cmd/compile/internal/staticinit: fix bug in global new(expr)

The StaticInit pass asserts that the operand of &v is a global,
but this is not so for the &autotemp desugaring of new(expr).

(The variable has by that point escaped to the heap, so
the object code calls runtime.newobject. A future optimization
would be to statically allocate the variable when it is safe
and advantageous to do so.)

Thanks to khr for suggesting the fix.

+ static test

Fixes #77237
Change-Id: I71b34a1353fe0f3e297beab9851f8f87d765d8f1
Reviewed-by: Keith Randall <k...@golang.org>
Reviewed-by: Keith Randall <k...@google.com>
Files:
  • M src/cmd/compile/internal/staticinit/sched.go
  • M test/newexpr.go
Change size: S
Delta: 2 files changed, 10 insertions(+), 0 deletions(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +2 by Keith Randall, +1 by Keith Randall
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I71b34a1353fe0f3e297beab9851f8f87d765d8f1
Gerrit-Change-Number: 737680
Gerrit-PatchSet: 3
Gerrit-Owner: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Keith Randall <k...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages