For example, does the Go language spec guarantee the following will print true?

https://go.dev/play/p/Rybua4uBb87

package main

import "fmt"

func main() {
    fmt.Println(modify_result_parameter_after_return())
}

func modify_result_parameter_after_return() (b bool, _ error) {
    return b, set(&b)
}

func set(b *bool) error {
    *b = true

    return nil
}

4 Replies 4

it does not guarantee it, it's undefined behavior. https://github.com/golang/go/issues/58233

Your Reply

By clicking “Post Your Reply”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.