From patchwork Wed Jul 6 18:38:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 103567 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 48868B6F68 for ; Thu, 7 Jul 2011 04:38:56 +1000 (EST) Received: (qmail 4927 invoked by alias); 6 Jul 2011 18:38:55 -0000 Received: (qmail 4919 invoked by uid 22791); 6 Jul 2011 18:38:55 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, TW_JS, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 06 Jul 2011 18:38:30 +0000 Received: from wpaz17.hot.corp.google.com (wpaz17.hot.corp.google.com [172.24.198.81]) by smtp-out.google.com with ESMTP id p66IcUle013528 for ; Wed, 6 Jul 2011 11:38:30 -0700 Received: from iwg8 (iwg8.prod.google.com [10.241.66.136]) by wpaz17.hot.corp.google.com with ESMTP id p66IbnXG018797 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Wed, 6 Jul 2011 11:38:29 -0700 Received: by iwg8 with SMTP id 8so172212iwg.38 for ; Wed, 06 Jul 2011 11:38:29 -0700 (PDT) Received: by 10.231.26.87 with SMTP id d23mr8346693ibc.18.1309977509022; Wed, 06 Jul 2011 11:38:29 -0700 (PDT) Received: from coign.google.com ([2620:0:1000:2301:21c:25ff:fe14:8d86]) by mx.google.com with ESMTPS id w11sm5000184ibw.24.2011.07.06.11.38.28 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 06 Jul 2011 11:38:28 -0700 (PDT) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: libgo patch committed: Fix json test when rand returns 0 Date: Wed, 06 Jul 2011 11:38:26 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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)