Skip to content

gccgo: unexpected error on inlined routine calling varargs function #32922

@thanm

Description

@thanm

What version of Go are you using (go version)?

$ go version
gccgo (GCC) 10.0.0 20190703 (experimental)

What did you do?

Compile these two packages:

a.go

package a

func A() int {
	return p("count")
}

func p(which string, args ...string) int {
	switch which {
	case "count", "something":
		return 1
	default:
		return 2
	}
}

b.go

package b

import "a"

func B() int {
	return 99 + a.A()
}

using "go install a" then "go build b"

What did you expect to see?

Clean build

What did you see instead?

When compiling "b", this error:

$ go build .
# b
.../src/a/a.go:4:0: error: argument 2 has incompatible type

[Note that even though we are compiling b.go, the error is being reported in a.go]. Error is happening during lowering. At the call to go_error_at we are in:

#1  Call_expression::check_argument_type (...) go/expressions.cc:11861
#2  Call_expression::lower_varargs (...) go/expressions.cc:10914
#3  Call_expression::do_lower (...) go/expressions.cc:10763

It looks as though the argument type here is nil_type", and the parameter type is string type:

(gdb) p debug_go_type(parameter_type)
      T0   0x555559ad9fa0  'string' -> string
      T1   0x555559a4e000  string
$10 = void
(gdb) p debug_go_type(argument_type)
      T0   0x555559a4e0a0  nil_type
$11 = void
(gdb) 

Looking at the export data for the function:

func A () ($ret0 <type -11>) <inl:86>
// .../src/a/a.go:3
{ //4
$ret0 = .p("count", $nil) //4
return //4
} //0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions