mirror of
https://github.com/golang/go
synced 2024-11-26 15:56:57 -07:00
3391517c0e
An invalid program may produce invalid types. If the program calls unsafe.Sizeof on such a type, which is a compile-time computation, the size-computation must be able to handle it. Add the invalid type to the list of permissible basic types and give it a size of 1 (word). Fixes #52748. Change-Id: I6c409628f9b77044758caf71cdcb199f9e77adea Reviewed-on: https://go-review.googlesource.com/c/go/+/404894 Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
14 lines
296 B
Go
14 lines
296 B
Go
// errorcheck
|
|
|
|
// Copyright 2022 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package p
|
|
|
|
import "unsafe"
|
|
|
|
type S[T any] struct{}
|
|
|
|
const c = unsafe.Sizeof(S[[c]byte]{}) // ERROR "initialization loop"
|