Skip to content

cmd/compile: bad compilation #15854

Closed
Closed
@randall77

Description

@randall77
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

@dsnet

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions