Skip to content

gccgo: reflect.Value.Call fails with struct with empty struct field #26335

Closed
@ianlancetaylor

Description

@ianlancetaylor

This test case crashes when compiled with gccgo. The parameter s is read from the wrong position on the stack. The problem is most likely that the empty struct field in large leads to a disagreement between the Go code and libffi.

package main

import (
	"fmt"
	"reflect"
)

type large struct {
	f1, f2, f3, f4 *byte
	empty struct{}
}

func F(str string, l large, s []string) {
	if len(s) != 1 || s[0] != "hi" {
		fmt.Printf("bad value for s: %v\n", s)
		panic("bad slice")
	}
}

func main() {
	params := []reflect.Value{
		reflect.ValueOf("str"),
		reflect.ValueOf(large{}),
		reflect.ValueOf([]string{"hi"}),
	}
	reflect.ValueOf(F).Call(params)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions