-
Notifications
You must be signed in to change notification settings - Fork 18k
gccgo: inconsistent behaviour of %s fmt verb #23642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Modifying the example slightly:
https://play.golang.org/p/_jgX6qz3cvB produces an NPE under cmd/compile but prints |
Duplicate of #19806, I think. |
@ianlancetaylor do you think the fix for #19806 also fixes this issue? I think there may be a second bug here (the behaviour of |
@tamird The two programs above now behave the same with gccgo as they do with gc. What leads you to think there is a second bug here? |
I cannot reproduce the "What did you see instead?" output with the OP playground link. package main
import (
"fmt"
)
type foo struct{}
func (foo) String() string {
return "hello"
}
type baz struct{}
func (*baz) String() string {
return "hello"
}
func main() {
fmt.Printf("%s\n", (*foo)(nil))
fmt.Printf("%s\n", (*baz)(nil))
} Output:
Seems to work as intended. |
@cznic did you test this in gccgo? @ianlancetaylor I don't see how the fix (explicit nil check) would change the behaviour of |
Heh, no, sorry. Missed that piece of info. The playground link convinced me, mistakenly, that it fails using the playground. |
@tamird |
Ah, didn't know that. Works for me, thanks! |
What version of Go are you using (
go version
)?go version go1.10rc1 gccgo (GCC) 8.0.1 20180131 (experimental) linux/amd64
Does this issue reproduce with the latest release?
N/A
What operating system and processor architecture are you using (
go env
)?What did you do?
https://play.golang.org/p/c7WLq7pKKYv
What did you expect to see?
<nil>
What did you see instead?
hello
The text was updated successfully, but these errors were encountered: