From patchwork Wed Jul 6 18:38:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: libgo patch committed: Fix json test when rand returns 0 From: Ian Taylor X-Patchwork-Id: 103567 Message-Id: To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Date: Wed, 06 Jul 2011 11:38:26 -0700 This patch is necessary when compiling the test cases with optimization, which changes the order of the calls to rand. I proposed the same patch to the upstream library. Bootstrapped and tested on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r 48658f7ed377 libgo/go/json/scanner_test.go --- a/libgo/go/json/scanner_test.go Fri Jun 24 07:06:48 2011 -0700 +++ b/libgo/go/json/scanner_test.go Wed Jul 06 11:35:51 2011 -0700 @@ -252,6 +252,9 @@ if f > n { f = n } + if n > 0 && f == 0 { + f = 1 + } x := make([]interface{}, int(f)) for i := range x { x[i] = genValue(((i+1)*n)/f - (i*n)/f)