Skip to content

cgo only generates correct multiple-value function invocations on first use #967

@chressie

Description

@chressie
What steps will reproduce the problem?

Compile the following code snippet with cgo:

package main

// static int f() {
//  return 1;
// }
import "C"

func main() {
    _, _ = C.f()
    _, _ = C.f()
}

What is the expected output?

File test.cgo1.go should read:

// Created by cgo - DO NOT EDIT
//line test.go:1
package main


func main() {
    _, _ = _C2func_f()
    _, _ = _C2func_f()
}

What do you see instead?

In the generated file, the second call to f() does not invoke the expected function:

// Created by cgo - DO NOT EDIT
//line test.go:1
package main


func main() {
    _, _ = _C2func_f()
    _, _ = _Cfunc_f()
}

What is your $GOOS?  $GOARCH?

GOOS=linux
GOARCH=amd64

Which revision are you using?  (hg identify)

46409b5999ae tip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions