Skip to content
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

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

Closed
zigo101 opened this issue Jan 5, 2022 · 3 comments
Closed

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

zigo101 opened this issue Jan 5, 2022 · 3 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@zigo101
Copy link

zigo101 commented Jan 5, 2022

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)
      |                        ^
@gopherbot gopherbot added this to the Gccgo milestone Jan 5, 2022
@ianlancetaylor
Copy link
Member

Looks like a bug in gccgo. Thanks.

@ianlancetaylor ianlancetaylor changed the title cmd/compile, gccgo: disagree on a conversion gccgo: does not permit conversion of slice ignoring struct tags Jan 5, 2022
@ianlancetaylor ianlancetaylor added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 5, 2022
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/375796 mentions this issue: test: add test of incorrect gofrontend error

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/375797 mentions this issue: compiler: permit converting unnamed types when ignoring struct tags

gopherbot pushed a commit that referenced this issue Jan 6, 2022
For #50439

Change-Id: Ifad6e6f8de42121c695b5a4dc56e0f6606e2917e
Reviewed-on: https://go-review.googlesource.com/c/go/+/375796
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Trust: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
jproberts pushed a commit to jproberts/go that referenced this issue Jun 21, 2022
For golang#50439

Change-Id: Ifad6e6f8de42121c695b5a4dc56e0f6606e2917e
Reviewed-on: https://go-review.googlesource.com/c/go/+/375796
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Trust: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
@golang golang locked and limited conversation to collaborators Jan 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants