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

cmd/compile: linkname symbol redeclared, unknown line number #59313

Closed
ii64 opened this issue Mar 29, 2023 · 1 comment
Closed

cmd/compile: linkname symbol redeclared, unknown line number #59313

ii64 opened this issue Mar 29, 2023 · 1 comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge

Comments

@ii64
Copy link

ii64 commented Mar 29, 2023

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

$ go version
go1.20

Does this issue reproduce with the latest release?

Yes, go1.20, go1.21, tip

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

go env Output
$ go env
[go playground]

What did you do?

package main

import (
	"fmt"
	"unsafe"
)

type M struct {
	p string
}

var k = []*M{
	{"a"}, {"b"}, {"c"},
}

//go:linkname x main.k
var x unsafe.Pointer

func main() {
	fmt.Println(k)
	fmt.Println(x)
}

Go playground link: https://go.dev/play/p/TzmdH78MJj-

What did you expect to see?

Address of k

What did you see instead?

./prog.go:14:5: <unknown line number>: symbol main.k redeclared

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Mar 29, 2023
@mknyszek
Copy link
Contributor

There should be a better error message, but to clarify go:linkname does actually define a new symbol, hence the message. The error overall is expected.

Since go:linkname is meant for internal low-level use-cases, we're inclined to close this issue.

@golang golang locked and limited conversation to collaborators Mar 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge
Projects
None yet
Development

No branches or pull requests

3 participants