Skip to content

gccgo: does not permit conversion of slice ignoring struct tags #50439

@zigo101

Description

@zigo101

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

$ go version
go version go1.18beta1 linux/amd64

$ gccgo --version
gccgo (Debian 10.2.1-6) 10.2.1 20210110

Does this issue reproduce with the latest release?

Yes

What did you do?

package main

type Person = struct {
	Name    string
	Address *struct {
		Street string
		City   string
	}
}

var data []struct {
	Name    string `json:"name"`
	Address *struct {
		Street string `json:"street"`
		City   string `json:"city"`
	} `json:"address"`
}

var person = ([]Person)(data)

func main() {}

What did you expect to see?

Same behavior

What did you see instead?

$ go run main.go

$ go run -compiler=gccgo main.go
# command-line-arguments
./main.go:19:24: error: invalid type conversion
   19 | var person = ([]Person)(data)
      |                        ^

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.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions