Skip to content
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

cmd/gc: disagrees with spec in result of []byte("") #5704

Closed
robpike opened this issue Jun 14, 2013 · 6 comments
Closed

cmd/gc: disagrees with spec in result of []byte("") #5704

robpike opened this issue Jun 14, 2013 · 6 comments
Milestone

Comments

@robpike
Copy link
Contributor

robpike commented Jun 14, 2013

package main

import (
    "fmt"
)

func main() {
    a := []byte(nil)
    b := []byte("") // "If the string is empty, the result is []byte(nil)."
    fmt.Println((a == nil) == (b == nil))
}
@minux
Copy link
Member

minux commented Jun 15, 2013

Comment 1:

converting "" to []rune is also incorrect wrt the spec.
http://play.golang.org/p/0k8nFTaa5g
package main
func main() {
        a := []byte(nil)
        b := []byte("") // "If the string is empty, the result is []byte(nil)."
        c := []rune(nil)
        d := []rune("") // "If the string is empty, the result is []rune(nil)."
        println(a, b, (a == nil) == (b == nil))
        println(c, d, (c == nil) == (d == nil))
}

@minux
Copy link
Member

minux commented Jun 15, 2013

Comment 2:

gccgo is also affected.

@robpike
Copy link
Contributor Author

robpike commented Jun 15, 2013

Comment 3:

Labels changed: added go1.2.

@rsc
Copy link
Contributor

rsc commented Jun 21, 2013

Comment 4:

If gc and gccgo agree about the behavior, maybe it's a spec bug. It seems weird to me to
mandate that a computation generate nil. []byte("") looks a lot like []byte{}, and the
latter is non-nil.
Robert?

@griesemer
Copy link
Contributor

Comment 5:

https://golang.org/cl/10440045

Owner changed to @griesemer.

@griesemer
Copy link
Contributor

Comment 6:

This issue was closed by revision de47f68.

Status changed to Fixed.

@rsc rsc added this to the Go1.2 milestone Apr 14, 2015
@rsc rsc removed the go1.2 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants