Skip to content

cmd/compile: failure to reject initialization loop #21752

Closed
@mdempsky

Description

@mdempsky

cmd/compile accepts this bit of code, while go/types and gccgo reject it as an initialization cycle ("A refers to A"):

var A = func() int {
	if false {
		return A
	}
	return 0
}()

https://play.golang.org/p/jpUoGbyJqX

Related #21750. The common issue here is probably that we're performing initialization order analysis based on the optimized/inlined functions rather than the original Go source.

/cc @griesemer

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions