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

gccgo: math.Ceil returns positive zero on negative input #23647

Closed
tamird opened this issue Feb 1, 2018 · 4 comments
Closed

gccgo: math.Ceil returns positive zero on negative input #23647

tamird opened this issue Feb 1, 2018 · 4 comments
Milestone

Comments

@tamird
Copy link
Contributor

tamird commented Feb 1, 2018

What version of Go are you using (go version)?

go version go1.10rc1 gccgo (GCC) 8.0.1 20180131 (experimental) linux/amd64

Does this issue reproduce with the latest release?

N/A

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/tduberstein/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/tduberstein/local/go"
GORACE=""
GOROOT="/home/tduberstein/local/gcc/gcc"
GOTMPDIR=""
GOTOOLDIR="/home/tduberstein/local/gcc/gcc/libexec/gcc/x86_64-pc-linux-gnu/8.0.1"
GCCGO="/home/tduberstein/local/gcc/gcc/bin/gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build297122770=/tmp/go-build -gno-record-gcc-switches -funwind-tables"

What did you do?

package main

import (
        "fmt"
        "math"
)

func main() {
        fmt.Println(math.Ceil(-0.9))
}

What did you expect to see?

-0

What did you see instead?

0

@gopherbot gopherbot added this to the Gccgo milestone Feb 1, 2018
@odeke-em
Copy link
Member

odeke-em commented Feb 1, 2018

/cc @thanm @ianlancetaylor

@gopherbot
Copy link

Change https://golang.org/cl/91297 mentions this issue: math: add tests for Ceil/Floor/Trunc of -0.9

@gopherbot
Copy link

Change https://golang.org/cl/91335 mentions this issue: math: test for pos/neg zero return of Ceil/Floor/Trunc

@gopherbot
Copy link

Change https://golang.org/cl/91355 mentions this issue: math: adjust compilation flags, use them when testing

hubot pushed a commit to gcc-mirror/gcc that referenced this issue Feb 1, 2018
    
    We were using special compilation flags for the math package, but we
    weren't using them when testing.  That meant that our tests were not
    checking the real code we were providing.  Fix that.
    
    Fixing that revealed that we were not using a good set of flags, or at
    least were not using flags that let the tests pass.  Adjust the flags
    to stop using -funsafe-math-optimizations on x86.  Instead always use
    -ffp-contract=off -fno-math-errno -fno-trapping-math for all targets.
    
    Fixes golang/go#23647
    
    Reviewed-on: https://go-review.googlesource.com/91355


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@257312 138bc75d-0d04-0410-961f-82ee72b054a4
gopherbot pushed a commit that referenced this issue Aug 21, 2018
Ceil and Trunc of -0.2 return -0, not +0, but we didn't test that.

Updates #23647

Change-Id: Idbd4699376abfb4ca93f16c73c114d610d86a9f2
Reviewed-on: https://go-review.googlesource.com/91335
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
@golang golang locked and limited conversation to collaborators Feb 1, 2019
asiekierka pushed a commit to WonderfulToolchain/gcc-ia16 that referenced this issue May 16, 2022
    
    We were using special compilation flags for the math package, but we
    weren't using them when testing.  That meant that our tests were not
    checking the real code we were providing.  Fix that.
    
    Fixing that revealed that we were not using a good set of flags, or at
    least were not using flags that let the tests pass.  Adjust the flags
    to stop using -funsafe-math-optimizations on x86.  Instead always use
    -ffp-contract=off -fno-math-errno -fno-trapping-math for all targets.
    
    Fixes golang/go#23647
    
    Reviewed-on: https://go-review.googlesource.com/91355

From-SVN: r257312
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants