...
Run Format

Source file test/fixedbugs/issue13171.go

Documentation: test/fixedbugs

     1  // run
     2  
     3  // Copyright 2015 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  package main
     8  
     9  // Make sure the compiler knows that DUFFCOPY clobbers X0
    10  
    11  import "fmt"
    12  
    13  //go:noinline
    14  func f(x float64) float64 {
    15  	// y is allocated to X0
    16  	y := x + 5
    17  	// marshals z before y.  Marshaling z
    18  	// calls DUFFCOPY.
    19  	return g(z, y)
    20  }
    21  
    22  //go:noinline
    23  func g(b [64]byte, y float64) float64 {
    24  	return y
    25  }
    26  
    27  var z [64]byte
    28  
    29  func main() {
    30  	got := f(5)
    31  	if got != 10 {
    32  		panic(fmt.Sprintf("want 10, got %f", got))
    33  	}
    34  }
    35  

View as plain text