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

cmd/compile: expected "not used" error #35021

Open
serhatgiydiren opened this issue Oct 20, 2019 · 1 comment
Open

cmd/compile: expected "not used" error #35021

serhatgiydiren opened this issue Oct 20, 2019 · 1 comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@serhatgiydiren
Copy link
Contributor

serhatgiydiren commented Oct 20, 2019

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

$ go version
go version go1.13.1 linux/amd64

Does this issue reproduce with the latest release?

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/me/.cache/go-build"
GOENV="/home/me/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/me/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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-build399130454=/tmp/go-build -gno-record-gcc-switches"
GOROOT/bin/go version: go version go1.13.1 linux/amd64
GOROOT/bin/go tool compile -V: compile version go1.13.1
uname -sr: Linux 5.0.0-31-generic
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.3 LTS
Release:	18.04
Codename:	bionic
/lib/x86_64-linux-gnu/libc.so.6: GNU C Library (Ubuntu GLIBC 2.27-3ubuntu1) stable release version 2.27.
gdb --version: GNU gdb (Ubuntu 8.1-0ubuntu3.1) 8.1.0.20180409-git

What did you do?

https://play.golang.org/p/O_76qweGQ0g

package main

func main() {
	var x int
	x = 7 - x
}

What did you expect to see?

Although x is used in assignment over itself, there is no usage of x, it is nice to get "not used" error for preventing unnecessary computations.

What did you see instead?

Nothing, run successfully

@ianlancetaylor ianlancetaylor changed the title Expected "not used" error cmd/compile: expected "not used" error Oct 20, 2019
@ianlancetaylor
Copy link
Contributor

ianlancetaylor commented Oct 20, 2019

At this date I would worry that making this change would cause many correct Go programs to stop compiling.

See #20802 for a related issue.

@ianlancetaylor ianlancetaylor added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 20, 2019
@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Oct 20, 2019
@golang golang deleted a comment from laothuong Oct 21, 2019
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants