1
0
mirror of https://github.com/golang/go synced 2024-11-15 01:40:25 -07:00
go/test/fixedbugs/issue42753.go
Keith Randall a2adbc876e [release-branch.go1.15] cmd/compile: sign extend consant folding properly
MOVLconst must have a properly sign-extended auxint constant.
The bit operations in these rules don't enforce that invariant.

The easiest fix is just to turn on properly typed auxint fields
(which is what fixed this issue at tip).

Fixes #42753

Change-Id: I264245fad45067a6ade65326f7fe681feb5f3739
Reviewed-on: https://go-review.googlesource.com/c/go/+/272028
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2020-12-03 13:58:28 +00:00

14 lines
285 B
Go

// compile -d=ssa/check/on
// Copyright 2020 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 main
func f() uint32 {
s := "\x01"
x := -int32(s[0])
return uint32(x) & 0x7fffffff
}