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

Request for update(if possible) #40

Open
ShockYoungCHN opened this issue May 13, 2023 · 1 comment
Open

Request for update(if possible) #40

ShockYoungCHN opened this issue May 13, 2023 · 1 comment

Comments

@ShockYoungCHN
Copy link

ShockYoungCHN commented May 13, 2023

After so many years, seems go compiler optimization have changed a lot. One problem is in chapter 2, iface.go, chapter 2. To make the assembly code call the function through itab func pointer,

func main() {
    m := Mather(Adder{id: 6754})
    // This call just makes sure that the interface is actually used.
    // Without this call, the linker would see that the interface defined above
    // is in fact never used, and thus would optimize it out of the final
    // executable.
    m.Add(10, 32)
}

should be changed to

func main() {
	var m Mather
	m = Adder{id: 6754}
	// This call just makes sure that the interface is actually used.
	// Without this call, the linker would see that the interface defined above
	// is in fact never used, and thus would optimize it out of the final
	// executable.
	m.Add(10, 32)
}

Or the assembly code would CALL "".Adder.Add(SB) directly.

@jsonlee0x01
Copy link

jsonlee0x01 commented May 13, 2023 via email

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

2 participants