From: Ian Lance Taylor Date: Wed, 6 Jul 2011 18:38:24 +0000 (+0000) Subject: json: fix test when rand returns 0. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d75dae75d741eb852f400ccda88079bc3f26a3ad;p=gcc.git json: fix test when rand returns 0. Fixes using gccgo when optimizing, which changes the order of calls to rand. Same patch proposed upstream. From-SVN: r175927 --- diff --git a/libgo/go/json/scanner_test.go b/libgo/go/json/scanner_test.go index 0d4de3246dd..df87c716aff 100644 --- a/libgo/go/json/scanner_test.go +++ b/libgo/go/json/scanner_test.go @@ -252,6 +252,9 @@ func genArray(n int) []interface{} { 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)