Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
zerosize.go34 linesDownload Raw Back to test
1// run2 3// Copyright 2023 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 7// Test that zero-sized variables get same address as8// runtime.zerobase.9 10package main11 12var x, y [0]int13var p, q = new([0]int), new([0]int) // should get &runtime.zerobase14 15func main() {16	if &x != &y {17		// Failing for now. x and y are at same address, but compiler optimizes &x==&y to false. Skip.18		// print("&x=", &x, " &y=", &y, " &x==&y = ", &x==&y, "\n")19		// panic("FAIL")20	}21	if p != q {22		print("p=", p, " q=", q, " p==q = ", p==q, "\n")23		panic("FAIL")24	}25	if &x != p {26		print("&x=", &x, " p=", p, " &x==p = ", &x==p, "\n")27		panic("FAIL")28	}29	if &y != p {30		print("&y=", &y, " p=", p, " &y==p = ", &y==p, "\n")31		panic("FAIL")32	}33}34 
codekingpro/portable-devtools · Team Ai