| 1 |
// run |
| 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 |
// Issue 26153. The write to ps was incorrectly |
| 8 |
// removed by the dead auto elimination pass. |
| 9 |
|
| 10 |
package main |
| 11 |
|
| 12 |
const hello = "hello world" |
| 13 |
|
| 14 |
func main() { |
| 15 |
var s string |
| 16 |
mangle(&s) |
| 17 |
if s != hello { |
| 18 |
panic("write incorrectly elided") |
| 19 |
} |
| 20 |
} |
| 21 |
|
| 22 |
//go:noinline |
| 23 |
func mangle(ps *string) { |
| 24 |
if ps == nil { |
| 25 |
var s string |
| 26 |
ps = &s |
| 27 |
} |
| 28 |
*ps = hello |
| 29 |
} |