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: uint assignment overflow but compile doesn't report error. #23163

Closed
mnhkahn opened this issue Dec 18, 2017 · 1 comment
Closed

math: uint assignment overflow but compile doesn't report error. #23163

mnhkahn opened this issue Dec 18, 2017 · 1 comment

Comments

@mnhkahn
Copy link

mnhkahn commented Dec 18, 2017

Please answer these questions before submitting your issue. Thanks!

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

go version go1.8.3 windows/amd64

Does this issue reproduce with the latest release?

No

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

set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=E:\dev\gopath
set GORACE=
set GOROOT=E:\Go
set GOTOOLDIR=E:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
set PKG_CONFIG=pkg-config
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2

What did you do?

Assign a uint64 number to type of uint, it can build and run.

package main

import (
	"fmt"
	"math"
	"runtime"
)

func main() {
	var a uint = math.MaxUint64
	fmt.Println("Hello, playground", a, runtime.Version())
}

What did you expect to see?

Build error with messge: constant 18446744073709551615 overflows uint

What did you see instead?

Hello, playground 18446744073709551615 go1.8.3

@davecheney
Copy link
Contributor

Thank you for raising this issue. Unlike many projects on GitHub, the Go project does not use its bug tracker for general discussion or asking questions. We only use our bug tracker for tracking bugs and tracking proposals going through the Proposal Process.

uint is a variable sized type, on your 64 bit computer uint is 64 bits wide.

Please see https://golang.org/wiki/Questions for good places to ask questions.

@mikioh mikioh changed the title uint assignment overflow but compile doesn't report error. math: uint assignment overflow but compile doesn't report error. Jan 5, 2018
@golang golang locked and limited conversation to collaborators Jan 5, 2019
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