Skip to content

compiler: dead code and labels cause compilation failure #66803

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

Closed
Bios-Marcel opened this issue Apr 12, 2024 · 3 comments
Closed

compiler: dead code and labels cause compilation failure #66803

Bios-Marcel opened this issue Apr 12, 2024 · 3 comments

Comments

@Bios-Marcel
Copy link

Go version

go version go1.22.1 windows/amd64

Output of go env in your module/workspace:

set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\marce\AppData\Local\go-build
set GOENV=C:\Users\marce\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\marce\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\marce\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Users\marce\scoop\apps\go\current
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Users\marce\scoop\apps\go\current\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.22.1
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\marce\code\spoon\compilerbug\go.mod
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\marce\AppData\Local\Temp\go-build2412120114=/tmp/go-build -gno-record-gcc-switches

What did you do?

I created the following main file:

package main

import (
	"fmt"
	"path/filepath"
)

func main() {
	fmt.Println("Start")
	call("")
	fmt.Println("End")
}

func call(parameter string) error {
	return nil

	ext := filepath.Join(parameter, "lol")
	if parameter != "" {
		goto LABEL
	}

LABEL:
	if ext != "" {
		fmt.Println("Label")
	}
	return nil
}

It contains unreachable code, but the compiler does not correctly interpret this and trips up instead.

What did you see happen?

PS C:\Users\marce\code\spoon\compilerbug> go run .
# bug
CLOSURE [C:\Users\marce\code\spoon\compilerbug\main.go:23:5:var ext string]
<unknown line number>: internal compiler error: assertion failed

Please file a bug report including a short program that triggers the error.
https://go.dev/issue/new

What did you expect to see?

Not an internal compiler error, but the normal behaviour.

@randall77
Copy link
Contributor

Possibly this is #65593, which is fixed in 1.22.2. Can you try that release?

@qiulaidongfeng
Copy link
Member

Possibly this is #65593, which is fixed in 1.22.2. Can you try that release?

I tried, go1.22.2 has no ICE.

@Bios-Marcel
Copy link
Author

Yup, seems fine on 1.22.2! Sorry for the bother.

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

4 participants