Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
nilptr5.go39 linesDownload Raw Back to test
1// errorcheck -0 -d=nil2 3//go:build !wasm && !aix4 5// Copyright 2018 The Go Authors. All rights reserved.6// Use of this source code is governed by a BSD-style7// license that can be found in the LICENSE file.8 9// Test that nil checks are removed.10// Optimization is enabled.11 12package p13 14func f5(p *float32, q *float64, r *float32, s *float64) float64 {15	x := float64(*p) // ERROR "removed nil check"16	y := *q          // ERROR "removed nil check"17	*r = 7           // ERROR "removed nil check"18	*s = 9           // ERROR "removed nil check"19	return x + y20}21 22type T struct{ b [29]byte }23 24func f6(p, q *T) {25	x := *p // ERROR "removed nil check"26	*q = x  // ERROR "removed nil check"27}28 29// make sure to remove nil check for memory move (issue #18003)30func f8(t *struct{ b [8]int }) struct{ b [8]int } {31	return *t // ERROR "removed nil check"32}33 34// nil check is removed for pointer write (which involves a35// write barrier).36func f9(x **int, y *int) {37	*x = y // ERROR "removed nil check"38}39 
codekingpro/portable-devtools · Team Ai