1
0
mirror of https://github.com/golang/go synced 2024-11-25 22:47:57 -07:00
go/test/fixedbugs/issue52193.go
Filippo Valsorda 566cf1c108 crypto/ecdh: move implementation to crypto/internal/fips/ecdh
This intentionally gives up on the property of not computing the public
key until requested. It was nice, but it was making the code too
complex. The average use case is to call PublicKey immediately after
GenerateKey anyway.

Added support in the module for P-224, just in case we'd ever want to
support it in crypto/ecdh.

Tried various ways to fix test/fixedbugs/issue52193.go to be meaningful,
but crypto/ecdh is pretty complex and all the solutions would end up
locking in crypto/ecdh structure rather than compiler behavior. The rest
of that test is good enough on its own anyway. If we do the work in the
future of making crypto/ecdh zero-allocations using the affordances of
the compiler, we can add a more robust TestAllocations on our side.

For #69536

Change-Id: I68ac3955180cb31f6f96a0ef57604aaed88ab311
Reviewed-on: https://go-review.googlesource.com/c/go/+/628315
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Russ Cox <rsc@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-19 23:01:37 +00:00

26 lines
639 B
Go

// errorcheck -0 -m
// Copyright 2023 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
// Test that inlining doesn't break if devirtualization exposes a new
// inlinable callee.
func f() { // ERROR "can inline f"
var i interface{ m() } = T(0) // ERROR "T\(0\) does not escape"
i.m() // ERROR "devirtualizing i.m" "inlining call to T.m"
}
type T int
func (T) m() { // ERROR "can inline T.m"
if never {
f() // ERROR "inlining call to f" "devirtualizing i.m" "T\(0\) does not escape"
}
}
var never bool