codekingpro/portable-devtools
114k
1// run2 3// Copyright 2025 The Go Authors. All rights reserved.4// Use of this source code is governed by a BSD-style5// license that can be found in the LICENSE file.6 7package main8 9// Issue #45624 is the proposal to accept new(expr) in go1.26.10// Here we test its run-time behavior.11func main() {12 {13 p := new(123) // untyped constant expr14 if *p != 123 {15 panic("wrong value")16 }17 }18 {19 x := 4220 p := new(x) // non-constant expr21 if *p != x {22 panic("wrong value")23 }24 }25 {26 x := [2]int{123, 456}27 p := new(x) // composite value28 if *p != x {29 panic("wrong value")30 }31 }32 {33 var i int34 v := new(i > 0) // untyped expression, see issue #7561735 if *v != false {36 panic("wrong value")37 }38 }39}40 41// Regression test for ICE in staticdata.GlobalLinksym from42// use of autotemp outside a function (go.dev/issue/77237).43var (44 x = new(0)45 y = x46)47 