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

gccgo: fails to order evaluation of some bound method expression thunks #49512

Closed
ianlancetaylor opened this issue Nov 10, 2021 · 2 comments
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@ianlancetaylor
Copy link
Contributor

This test case panics when compiled with gccgo. I'm working on a fix.

package main

type S struct{
	m1Called, m2Called bool
}

func (s *S) M1(int) (int, int) {
	s.m1Called = true
	return 0, 0
}

func (s *S) M2(int) (int, int) {
	s.m2Called = true
	return 0, 0
}

type C struct {
	calls []func(int) (int, int)
}

func makeC() Funcs {
	return &C{}
}

func (c *C) Add(fn func(int) (int, int)) Funcs {
	c.calls = append(c.calls, fn)
	return c
}

func (c *C) Call() {
	for _, fn := range c.calls {
		fn(0)
	}
}

type Funcs interface {
	Add(func(int) (int, int)) Funcs
	Call()
}

func main() {
	s := &S{}
	c := makeC().Add(s.M1).Add(s.M2)
	c.Call()
	if !s.m1Called || !s.m2Called {
		panic("missed method call")
	}
}
@ianlancetaylor ianlancetaylor added the NeedsFix The path to resolution is known, but the work has not been done. label Nov 10, 2021
@ianlancetaylor ianlancetaylor added this to the Gccgo milestone Nov 10, 2021
@ianlancetaylor ianlancetaylor self-assigned this Nov 10, 2021
@gopherbot
Copy link

Change https://golang.org/cl/363156 mentions this issue: test: add test that was miscompiled by gccgo

@gopherbot
Copy link

Change https://golang.org/cl/363274 mentions this issue: compiler: traverse func subexprs when creating func descriptors

gopherbot pushed a commit that referenced this issue Nov 11, 2021
For #49512

Change-Id: Ic08652a4ec611b27150bf10b1118c1395715e5d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/363156
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
@golang golang locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

2 participants