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

runtime: Different output when compiling with -gcflags 'all=-N -l #60066

Closed
chenmingyong0423 opened this issue May 9, 2023 · 0 comments
Closed

Comments

@chenmingyong0423
Copy link

Environment

windows10 
go1.20.1

Problem

When I compiled my code with go 1.20.1, I found that the results of the program executed with the -gcflags "all=-N -l" compiler flag were inconsistent with those without.

The code looks like this:

package main

func foo() {
	println("foo")
}

var list = []func(){
	func() {
		println("1")
	},
	func() {
		println("2")
	},
	func() {
		println("3")
	},
}

func main() {
	fn := foo
	for _, fn = range list {
		fn()
	}
}

QQ图片20230509110824

Why is there a difference in program execution results when using the -gcflags "all=-N -l" compilation flag, and is this a bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant