Skip to content

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

@mnhkahn

Description

@mnhkahn

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions