From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 113809 invoked by alias); 17 Jun 2017 12:12:50 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 113769 invoked by uid 89); 17 Jun 2017 12:12:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 17 Jun 2017 12:12:44 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C9D8B80C02; Sat, 17 Jun 2017 12:12:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C9D8B80C02 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jwakely@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C9D8B80C02 Received: from localhost (unknown [10.33.36.93]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7B93017AD8; Sat, 17 Jun 2017 12:12:47 +0000 (UTC) Date: Sat, 17 Jun 2017 12:12:00 -0000 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: [PATCH] PR libstdc++/80893 Fix null dereference in vector Message-ID: <20170617121246.GD5211@redhat.com> References: <20170531124542.GA21387@redhat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="+QahgC5+KEYLbs62" Content-Disposition: inline In-Reply-To: <20170531124542.GA21387@redhat.com> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.8.0 (2017-02-23) X-SW-Source: 2017-06/txt/msg01254.txt.bz2 --+QahgC5+KEYLbs62 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline Content-length: 852 On 31/05/17 13:45 +0100, Jonathan Wakely wrote: >vector does addressof(*ptr) where ptr is returned by >allocate(n), but if n==0 that pointer might not be dereferencable. > >While testing the fix I also found some bugs in the >__gnu_test::PointerBase helper that needed correcting. > > PR libstdc++/80893 > * include/bits/stl_bvector.h (vector::_M_initialize): Avoid > null pointer dereference when size is zero. > * testsuite/23_containers/vector/bool/80893.cc: New. > * testsuite/util/testsuite_allocator.h (PointerBase::PointerBase): > Add non-explicit constructor from nullptr. > (PointerBase::derived() const): Add const-qualified overload. > >Tested powerpc64le-linux, committed to trunk. The new test fails in C++98 modes, as shown at https://gcc.gnu.org/ml/gcc-testresults/2017-06/msg01833.html Fixed like so, committed to trunk. --+QahgC5+KEYLbs62 Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" Content-length: 773 commit c8315ef81030c2d3d284c2dc3d545419243216c3 Author: Jonathan Wakely Date: Sat Jun 17 12:46:18 2017 +0100 PR libstdc++/80893 don't run test for C++98 modes PR libstdc++/80893 * testsuite/23_containers/vector/bool/80893.cc: Add { target c++11 }. diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/80893.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/80893.cc index 0545b38..0b0016c 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/bool/80893.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/80893.cc @@ -15,6 +15,8 @@ // with this library; see the file COPYING3. If not see // . +// { dg-do run { target c++11 } } + // libstdc++/80893 #include --+QahgC5+KEYLbs62--