Open dgryski opened 10 months ago
Huh, that's interesting.
I'd have to investigate, but I expect this to be a bug in the golang.org/x/tools/go/ssa package.
I agree. Here is a dump of the SSA code generated for main
:
func main():
0: entry P:0 S:0
t0 = new string (s1) *string
*t0 = "hello":string
t1 = *t0 string
t2 = toUpper(t0) error
t3 = *t0 string
t4 = println(t3, t1, t2) ()
return
And TinyGo is doing a faithful translation of those instructions.
@dgryski the output of ssadump
looks different than what I saw. What was the command you used to produce this?
This might already be known: https://github.com/golang/go/issues/48105
So this is undefined behaviour in Go. The compiler does one this. The SSA package (and this tinygo) and gccgo take a different interpretation.
Via @ydnar