Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

math: Different downcast behavior depending on platform #64444

Closed
nseba opened this issue Nov 29, 2023 · 1 comment
Closed

math: Different downcast behavior depending on platform #64444

nseba opened this issue Nov 29, 2023 · 1 comment

Comments

@nseba
Copy link

nseba commented Nov 29, 2023

Go version

1.21

What operating system and processor architecture are you using (go env)?

GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/opt/go/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/opt/go/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.4'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/seba/dev/logiccloud/rounding-test/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/65/jfg8j9sn7jdftxk_ny295yvh0000gn/T/go-build2794130776=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

Converting a float32 to an integer type has different behaviors on darwin/arm64 vs x86 when the float value overflows the target integer type. A sample project can be found here: https://go.dev/play/p/WZoGD3q1LBx

What did you expect to see?

darwin/arm64

float64 int8 uint8 uint64
3.4028234663852886e+38 -1 255 18446744073709551615
-3.4028234663852886e+38 0 0 0
256 0 0 256
-1.4 -1 255 0

What did you see instead?

linux/x86

float64 int8 uint8 uint64
3.4028234663852886e+38 0 0 9223372036854775808
-3.4028234663852886e+38 0 0 9223372036854775808
256 0 0 256
-1.4 -1 255 18446744073709551615
@seankhliao
Copy link
Member

Duplicate of #19405

@seankhliao seankhliao marked this as a duplicate of #19405 Nov 29, 2023
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants