Skip to content

cmd/compile: ICE with bodyfull linknames #80817

Closed as duplicate
Closed as duplicate

Description

@mateusz834

Consider:

package main

import (
	"net"
	_ "unsafe"
)

//go:linkname a
func a() net.Addr {
	return &net.TCPAddr{}
}

//go:linkname b main.a
func b() net.Addr {
	return &net.UDPAddr{}
}

func main() {
	_ = b().(*net.UDPAddr)
}

This code fails with:

[mateusz@arch fo ]$ go run .
# foo
./main.go:10:2: internal compiler error: panic: runtime error: invalid memory address or nil pointer dereference

Please file a bug report including a short program that triggers the error.
https://go.dev/issue/new

Removing body out of b fixes this.

Activity

  1. mateusz834 commented on Aug 10, 2026

    @mateusz834
    MemberAuthor

    I think it should fail with an explicit error, but not sure.

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

    compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions