Skip to content

cmd/compile: panic: Non-SSAable value should be a named location: foo.rts #35213

@mattn

Description

@mattn

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

$ go version
go version devel +adef06c7a5 Mon Oct 28 12:35:06 2019 +0000 windows/amd64

Does this issue reproduce with the latest release?

No.

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

go env Output
$ go env
set GO111MODULE=auto
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\mattn\AppData\Local\go-build
set GOENV=C:\Users\mattn\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\mattn\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\dev\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\dev\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\mattn\AppData\Local\Temp\go-build784877526=/tmp/go-build -gno-record-gcc-switches

What did you do?

main.go

package main

/*
#include <stdlib.h>

typedef struct Point {
    int x;
    int y;
} Point;

typedef struct Points {
    Point* points;
	int length;
} Points;

typedef struct Rect {
    Points rts;
} Rect;

struct Rect X() {
  struct Rect foo;
  return foo;
}

void Y(Points ps) {
}
*/
import "C"

func main() {
	foo := C.X()
	defer C.Y(foo.rts)
}

Compiling this code

What did you expect to see?

Success to compile

What did you see instead?

# command-line-arguments
panic: Non-SSAable value should be a named location: foo.rts

goroutine 21 [running]:
cmd/compile/internal/gc.(*state).openDeferSave(0xc0002d2480, 0xc000319f00, 0xc00044ae40, 0xc0004988c0, 0xc000498700)
	C:/dev/go/src/cmd/compile/internal/gc/ssa.go:4184 +0x7a1
cmd/compile/internal/gc.(*state).openDeferRecord(0xc0002d2480, 0xc000319e80)
	C:/dev/go/src/cmd/compile/internal/gc/ssa.go:4130 +0x237
cmd/compile/internal/gc.(*state).stmt(0xc0002d2480, 0xc000319f80)
	C:/dev/go/src/cmd/compile/internal/gc/ssa.go:1080 +0x16f8
cmd/compile/internal/gc.(*state).stmtList(0xc0002d2480, 0xc00031a7e0)
	C:/dev/go/src/cmd/compile/internal/gc/ssa.go:1018 +0x5f
cmd/compile/internal/gc.buildssa(0xc0002b8dc0, 0x0, 0x0)
	C:/dev/go/src/cmd/compile/internal/gc/ssa.go:426 +0xc40
cmd/compile/internal/gc.compileSSA(0xc0002b8dc0, 0x0)
	C:/dev/go/src/cmd/compile/internal/gc/pgen.go:298 +0x64
cmd/compile/internal/gc.compileFunctions.func2(0xc000091500, 0xc00034ccb0, 0x0)
	C:/dev/go/src/cmd/compile/internal/gc/pgen.go:363 +0x50
created by cmd/compile/internal/gc.compileFunctions
	C:/dev/go/src/cmd/compile/internal/gc/pgen.go:361 +0x12f

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.release-blocker

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions