golang / go

The Go programming language

Home Page:https://go.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gccgo: compiles weird construct

dvyukov opened this issue · comments

gccgo successfully compiles the following program:

package main
import "fmt"

func main() {
    var a = complex()()
    var i interface{} = a
    fmt.Printf("i: %T %#v\n", i, i)
    fmt.Printf("a: %T %#v\n", a, a)
    fmt.Printf("i: %T %#v\n", i, i)
}

The program panics when executed:

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0]

goroutine 16 [running]:
reflect.rawString.pN13_reflect.rtype
    ../../../libgo/go/reflect/type.go:467
reflect.canonicalize
    ../../../libgo/go/reflect/type.go:1943
reflect.toType
    ../../../libgo/go/reflect/type.go:1964
reflect.TypeOf
    ../../../libgo/go/reflect/type.go:1032
fmt.printArg.pN6_fmt.pp
    ../../../libgo/go/fmt/print.go:745
fmt.doPrintf.pN6_fmt.pp
    ../../../libgo/go/fmt/print.go:1183
fmt.Fprintf
    ../../../libgo/go/fmt/print.go:188
fmt.Printf
    ../../../libgo/go/fmt/print.go:197
main.main
    /tmp/111.go:7
created by main
    ../../../libgo/runtime/go-main.c:48

gcc version 6.0.0 2015070 (experimental) (GCC)

CL https://golang.org/cl/12778 mentions this issue.