Russ Cox | 2b1c9b4 | 2012-02-16 23:49:30 -0500 | [diff] [blame] | 1 | // run |
Russ Cox | 272d156 | 2009-12-02 23:54:51 -0800 | [diff] [blame] | 2 | |
| 3 | // Copyright 2009 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 | // function call arg reordering was picking out 1 call that |
| 8 | // didn't need to be in a temporary, but it was picking |
| 9 | // out the first call instead of the last call. |
Péter Surányi | 9b6ccb1 | 2015-02-06 21:44:39 +0900 | [diff] [blame] | 10 | // http://golang.org/issue/370 |
Russ Cox | 272d156 | 2009-12-02 23:54:51 -0800 | [diff] [blame] | 11 | |
| 12 | package main |
| 13 | |
| 14 | var gen = 'a' |
Russ Cox | 00f9f0c | 2010-03-30 10:34:57 -0700 | [diff] [blame] | 15 | |
Russ Cox | 272d156 | 2009-12-02 23:54:51 -0800 | [diff] [blame] | 16 | func f(n int) string { |
Russ Cox | 00f9f0c | 2010-03-30 10:34:57 -0700 | [diff] [blame] | 17 | s := string(gen) + string(n+'A'-1) |
| 18 | gen++ |
| 19 | return s |
Russ Cox | 272d156 | 2009-12-02 23:54:51 -0800 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | func g(x, y string) string { |
| 23 | return x + y |
| 24 | } |
| 25 | |
| 26 | func main() { |
Russ Cox | 00f9f0c | 2010-03-30 10:34:57 -0700 | [diff] [blame] | 27 | s := f(1) + f(2) |
Russ Cox | 272d156 | 2009-12-02 23:54:51 -0800 | [diff] [blame] | 28 | if s != "aAbB" { |
Russ Cox | 00f9f0c | 2010-03-30 10:34:57 -0700 | [diff] [blame] | 29 | println("BUG: bug221a: ", s) |
| 30 | panic("fail") |
Russ Cox | 272d156 | 2009-12-02 23:54:51 -0800 | [diff] [blame] | 31 | } |
Russ Cox | 00f9f0c | 2010-03-30 10:34:57 -0700 | [diff] [blame] | 32 | s = g(f(3), f(4)) |
Russ Cox | 272d156 | 2009-12-02 23:54:51 -0800 | [diff] [blame] | 33 | if s != "cCdD" { |
Russ Cox | 00f9f0c | 2010-03-30 10:34:57 -0700 | [diff] [blame] | 34 | println("BUG: bug221b: ", s) |
| 35 | panic("fail") |
Russ Cox | 272d156 | 2009-12-02 23:54:51 -0800 | [diff] [blame] | 36 | } |
Russ Cox | 00f9f0c | 2010-03-30 10:34:57 -0700 | [diff] [blame] | 37 | s = f(5) + f(6) + f(7) + f(8) + f(9) |
Russ Cox | 272d156 | 2009-12-02 23:54:51 -0800 | [diff] [blame] | 38 | if s != "eEfFgGhHiI" { |
Russ Cox | 00f9f0c | 2010-03-30 10:34:57 -0700 | [diff] [blame] | 39 | println("BUG: bug221c: ", s) |
| 40 | panic("fail") |
Russ Cox | 272d156 | 2009-12-02 23:54:51 -0800 | [diff] [blame] | 41 | } |
| 42 | } |