Skip to content

cmd/compile: regression in taking pointer of array literal #20333

Closed

Description

@dsnet

Commit dfeecda from https://golang.org/cl/42175 caused a regression that causes this code to now fail to compile:

package main
import "fmt"
func main() {
	fmt.Println(&[...]string{"abc", "def", "ghi"})
}

The compiler output is:

# command-line-arguments
./main.go:8:46: use of [...] array outside of array literal
./main.go:8:46: internal compiler error: invalid alignment for [...]string

goroutine 1 [running]:
runtime/debug.Stack(0x0, 0x0, 0x0)
	/usr/local/go.tip/src/runtime/debug/stack.go:24 +0xa7
cmd/compile/internal/gc.Fatalf(0xb7ec95, 0x18, 0xc4203344d0, 0x1, 0x1)
	/usr/local/go.tip/src/cmd/compile/internal/gc/subr.go:181 +0x230
cmd/compile/internal/gc.dowidth(0xc42032e780)
	/usr/local/go.tip/src/cmd/compile/internal/gc/align.go:372 +0x304
cmd/compile/internal/gc.checkwidth(0xc42032e780)
	/usr/local/go.tip/src/cmd/compile/internal/gc/align.go:424 +0x17c
cmd/compile/internal/gc.typecheck1(0xc4202f5400, 0x44, 0x0)
	/usr/local/go.tip/src/cmd/compile/internal/gc/typecheck.go:501 +0x7e36
cmd/compile/internal/gc.typecheck(0xc4202f5400, 0x44, 0x0)
	/usr/local/go.tip/src/cmd/compile/internal/gc/typecheck.go:201 +0x78a
cmd/compile/internal/gc.typecheckcomplit(0xc4202f5080, 0x0)
	/usr/local/go.tip/src/cmd/compile/internal/gc/typecheck.go:2926 +0x13e
cmd/compile/internal/gc.typecheck1(0xc4202f5080, 0x12, 0xc420322f00)
	/usr/local/go.tip/src/cmd/compile/internal/gc/typecheck.go:837 +0x579b
cmd/compile/internal/gc.typecheck(0xc4202f5080, 0x12, 0xc420322f00)
	/usr/local/go.tip/src/cmd/compile/internal/gc/typecheck.go:201 +0x78a
cmd/compile/internal/gc.typecheck1(0xc4202f5000, 0x1, 0x4b3aba)
	/usr/local/go.tip/src/cmd/compile/internal/gc/typecheck.go:1250 +0x4e32
cmd/compile/internal/gc.typecheck(0xc4202f5000, 0x1, 0x3)
	/usr/local/go.tip/src/cmd/compile/internal/gc/typecheck.go:201 +0x78a
cmd/compile/internal/gc.typecheckslice(0xc42000c738, 0x1, 0x1, 0x1)
	/usr/local/go.tip/src/cmd/compile/internal/gc/typecheck.go:55 +0x46
cmd/compile/internal/gc.Main(0xb8f390)
	/usr/local/go.tip/src/cmd/compile/internal/gc/main.go:473 +0x1f22
main.main()
	/usr/local/go.tip/src/cmd/compile/main.go:49 +0x95

\cc @josharian

Activity

  1. added
    NeedsFixThe path to resolution is known, but the work has not been done.
    on May 11, 2017
  2. added this to the Go1.9 milestone on May 11, 2017
  3. josharian commented on May 11, 2017

    @josharian
    Contributor

    Thanks as always, @dsnet! Fix is on its way.

  4. gopherbot commented on May 11, 2017

    @gopherbot
    Contributor

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

  5. locked and limited conversation to collaborators on May 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions