Ian Lance Taylor | 47b6197 | 2012-03-22 09:44:31 -0700 | [diff] [blame] | 1 | // run |
| 2 | |
| 3 | // Copyright 2012 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 | // Test that when the compiler expands append inline it does not |
| 8 | // overwrite a value before it needs it (issue 3369). |
| 9 | |
| 10 | package main |
| 11 | |
| 12 | func main() { |
| 13 | s := make([]byte, 5, 6) |
| 14 | copy(s, "12346") |
| 15 | s = append(s[:len(s)-1], '5', s[len(s)-1]) |
| 16 | if string(s) != "123456" { |
| 17 | panic(s) |
| 18 | } |
| 19 | } |