Source file test/codegen/zerosize.go

     1  // asmcheck
     2  
     3  // Copyright 2018 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  // Make sure a pointer variable and a zero-sized variable
     8  // aren't allocated to the same stack slot.
     9  // See issue 24993.
    10  
    11  package codegen
    12  
    13  func zeroSize() {
    14  	c := make(chan struct{})
    15  	// amd64:`MOVQ\t\$0, command-line-arguments\.s\+56\(SP\)`
    16  	var s *int
    17  	// force s to be a stack object, also use some (fixed) stack space
    18  	g(&s, 1, 2, 3, 4, 5)
    19  
    20  	// amd64:`LEAQ\tcommand-line-arguments\..*\+55\(SP\)`
    21  	c <- struct{}{}
    22  }
    23  
    24  //go:noinline
    25  func g(**int, int, int, int, int, int) {}
    26  

View as plain text