From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id A56A53857809 for ; Tue, 20 Oct 2020 17:36:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A56A53857809 Received: from mail-il1-f198.google.com (mail-il1-f198.google.com [209.85.166.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-289-0neHIbTvNWe0piNK7HN-NQ-1; Tue, 20 Oct 2020 13:36:46 -0400 X-MC-Unique: 0neHIbTvNWe0piNK7HN-NQ-1 Received: by mail-il1-f198.google.com with SMTP id l11so959512ilq.21 for ; Tue, 20 Oct 2020 10:36:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:mime-version; bh=slmS5aXJBq2QcmnTPB5C8SlEOm+mNpi5FkdDODAs7bw=; b=Vllrkgjd7hY+graWsZwXgvWM0aOrJR4UMX+JN5MKZO+NfyXXAcfe/dGfungeqDlyu9 9KF8wutqLUKwXEjk69IHoMtVQV3dh+mLD1fwFrKLvGERWRQ0qe605XUBTQdAZ65+ZS/f OYWRguFbcwg6RfI9m8E1JTEkSAwhmgtbj8fu8euvHcnawnFqys7v40dDnPjpfpKjUwdR NO1VM2GhdF1OSSwXKkFNxaWRXskpkS6I3yakCQeK68OYltrwnNZkMg+NO9pu2htmOcbr HNqtrXWCcj4qcljUoMixtm+lKzB75/F+erQze9SQ0ekx2jAnXGv88XHhIFfs7Ga5+hKT WF0Q== X-Gm-Message-State: AOAM531FeKLTdD84+0j00eqF9BrvzWMWXltnFP6Vjk0+ptDnVLA8OmE5 0NzE5Oqdi4EFJSYzDaubGthbMOyrDCOIriZDhVmLtLYAtwUpeDK961bw1JUni30849ZXfb3zx7J WULC8mAxInc3K9cg= X-Received: by 2002:a05:6e02:1305:: with SMTP id g5mr2976733ilr.237.1603215405979; Tue, 20 Oct 2020 10:36:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcwWbSK0sSLt59WcfYe51HKwVjcdHA174H8TTYjMFi/0o77aLZYYUXZpq+g05DLkcrHhlDWQ== X-Received: by 2002:a05:6e02:1305:: with SMTP id g5mr2976715ilr.237.1603215405743; Tue, 20 Oct 2020 10:36:45 -0700 (PDT) Received: from [192.168.1.130] (ool-457d493a.dyn.optonline.net. [69.125.73.58]) by smtp.gmail.com with ESMTPSA id v88sm2599366ila.71.2020.10.20.10.36.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 10:36:44 -0700 (PDT) From: Patrick Palka X-Google-Original-From: Patrick Palka Date: Tue, 20 Oct 2020 13:36:43 -0400 (EDT) To: Jonathan Wakely cc: Patrick Palka , gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Subject: Re: [PATCH] libstdc++: Fix division by zero in std::sample In-Reply-To: <20201020170239.GA954627@redhat.com> Message-ID: References: <20200919010804.3509832-1-ppalka@redhat.com> <20200919010804.3509832-2-ppalka@redhat.com> <20200921150134.GE449323@redhat.com> <20201020170239.GA954627@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Oct 2020 17:36:53 -0000 On Tue, 20 Oct 2020, Jonathan Wakely wrote: > On 21/09/20 16:01 +0100, Jonathan Wakely wrote: > > On 18/09/20 21:08 -0400, Patrick Palka via Libstdc++ wrote: > > > This fixes a division by zero in the selection-sampling std::__search > > > overload when the input range is empty (and hence __unsampled_sz is 0). > > > > > > Tested on x86_64-pc-linux-gnu. > > > > > > libstdc++-v3/ChangeLog: > > > > > > * include/bits/stl_algo.h (__sample): Exit early when the > > > input range is empty. > > > * testsuite/25_algorithms/sample/3.cc: New test. > > > --- > > > libstdc++-v3/include/bits/stl_algo.h | 3 ++ > > > .../testsuite/25_algorithms/sample/3.cc | 50 +++++++++++++++++++ > > > 2 files changed, 53 insertions(+) > > > create mode 100644 libstdc++-v3/testsuite/25_algorithms/sample/3.cc > > > > OK, thanks. > > Could you please backport this to all branches too. Ah yes, sorry about losing track of this patch. I should be able to get the backports done by end of today.