Skip to content

gccgo: reflect.Type.Method doesn't correctly report variadic function #41737

Closed
@ianlancetaylor

Description

@ianlancetaylor

When the following program is run by the gc compiler it prints

in: 3; out: 0; variadic: true

When run by gccgo it prints

in: 3; out: 0; variadic: false

This is a bug somewhere in the gofrontend code.

package main

import (
	"fmt"
	"reflect"
)

type E struct{}

func (E) M(x string, xs ...int) {}

func main() {
	t := reflect.TypeOf(E{})
	for i := 0; i < t.NumMethod(); i++ {
		tm := t.Method(i).Type
		fmt.Printf("in: %d; out: %d; variadic: %t\n", tm.NumIn(), tm.NumOut(), tm.IsVariadic())
	}
}

CC @thanm @cherrymui @advancedwebdeveloper

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions