Closed
Description
package main
import (
"fmt"
)
type CIString struct {
_ [0]struct{ notComparable []byte }
Val string
}
// New creates a new CIString.
func New(str string) CIString {
return CIString{Val: str}
}
var a = New("ID")
func main() {
if a.Val != "ID" {
fmt.Printf("bad: %d %s\n", len(a.Val), a.Val)
}
}
When run, it often (with GOGC=1) prints the "bad" message and has varying junk for the string contents (but the length is always right).
The bug goes away with -gcflags=-ssa=0