From patchwork Sun Mar 17 17:14:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 228299 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 CC1ED2C00C4 for ; Mon, 18 Mar 2013 04:15:02 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1364145305; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Message-ID:Date:From:User-Agent:MIME-Version: To:CC:Subject:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=3Y2O4frgWCXYjOAsJWJA0QWJAdc=; b=n36A4oOh88/70vd dC/P8/m8ulpaFoSc5aizbA48LqvHgJyQ4+MgAT58hnoATh84lhQJNNCDD7dvBUdT ulzUlSVhAnE1IhhYdeezJQhQAjZmFVPdvZt++pPmEHtME83zJHh0kIEhsUOi/6hS P30XmuSsiJO7rOjS92BzRPL28GCA= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=lZ9CnrPqecEVzOZTi5F35Z3wRonnOJATdYw5zGf4mufpBIHbZm1blhp8CgVRA2 ezYkBpqp64cnyhAcqTkhd2qt9GrRxVAby4PrICe/Jdnd5n6biuFmzf+noUHJLk2e VJaW6kWM+SO0kcKUtQTX7PEHc0ltmLU54qe9eWRUegIRg=; Received: (qmail 5641 invoked by alias); 17 Mar 2013 17:14:50 -0000 Received: (qmail 5620 invoked by uid 22791); 17 Mar 2013 17:14:48 -0000 X-SWARE-Spam-Status: No, hits=-7.2 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 17 Mar 2013 17:14:42 +0000 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r2HHEepT012099 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 17 Mar 2013 17:14:41 GMT Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r2HHEeJl009293 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 17 Mar 2013 17:14:40 GMT Received: from abhmt120.oracle.com (abhmt120.oracle.com [141.146.116.72]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id r2HHEd30004038; Sun, 17 Mar 2013 12:14:39 -0500 Received: from [192.168.1.4] (/79.36.30.119) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 17 Mar 2013 10:14:39 -0700 Message-ID: <5145F9FC.7090808@oracle.com> Date: Sun, 17 Mar 2013 18:14:36 +0100 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130307 Thunderbird/17.0.4 MIME-Version: 1.0 To: libstdc++ CC: "gcc-patches@gcc.gnu.org" , Jonathan Wakely Subject: [v3] libstdc++/55979 (+ notes about 55977) 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 Hi, I had a look to these two PRs and, as regards the former, the below patchlet seems Ok to me even for 4.8.1. About the latter: a similar change works fine for std::vector and std::deque, but std::list for example has another problem, which is already exposed by the v1.emplace_back(i); bit and seems unrelated: we have: template struct _List_node : public __detail::_List_node_base { ///< User's data. _Tp _M_data; #if __cplusplus >= 201103L template _List_node(_Args&&... __args) : __detail::_List_node_base(), _M_data(std::forward<_Args>(__args)...) { } #endif }; together with: template _Node* _M_create_node(_Args&&... __args) { _Node* __p = this->_M_get_node(); __try { _M_get_Node_allocator().construct(__p, std::forward<_Args>(__args)...); } __catch(...) { _M_put_node(__p); __throw_exception_again; } return __p; } and this is not Ok in terms of access control, because _List_node tries to use the constructor, not the allocator (not sure how strict the Standard is in terms of access control) I guess we could at least work around the problem by going back to _M_get_Tp_allocator().construct in _M_create_node (or, better, the allocator_traits<>::construct equivalent, per the recent fix for 56613; we would use it on _Tp actually, everywhere) but I don't know if Jon has already something in his tree for this batch of issues regarding our base container class / node constructors, or we want to decouple the issue from 55977, do std::vector and std::deque, which would be trivial even for 4.8.1, or something else. Suggestions? Thanks! Paolo. ////////////////////////// 2013-03-17 Paolo Carlini PR libstdc++/55979 * include/bits/stl_list.h (_M_initialize_dispatch(_InputIterator, _InputIterator, __false_type)): Use emplace_back. * testsuite/23_containers/list/cons/55979.cc: New. * testsuite/23_containers/list/modifiers/1.h: Adjust. * testsuite/23_containers/list/requirements/dr438/assign_neg.cc: Adjust dg-error line number. Index: include/bits/stl_list.h =================================================================== --- include/bits/stl_list.h (revision 196754) +++ include/bits/stl_list.h (working copy) @@ -1487,7 +1487,11 @@ __false_type) { for (; __first != __last; ++__first) +#if __cplusplus >= 201103L + emplace_back(*__first); +#else push_back(*__first); +#endif } // Called by list(n,v,a), and the range constructor when it turns out Index: testsuite/23_containers/list/cons/55979.cc =================================================================== --- testsuite/23_containers/list/cons/55979.cc (revision 0) +++ testsuite/23_containers/list/cons/55979.cc (working copy) @@ -0,0 +1,34 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +struct A +{ + A(int) { } + A(const A&) = delete; + A& operator=(const A&) = delete; +}; + +void foo() +{ + int i[] = {1, 2}; + std::list li(i, i + 2); +} Index: testsuite/23_containers/list/modifiers/1.h =================================================================== --- testsuite/23_containers/list/modifiers/1.h (revision 196748) +++ testsuite/23_containers/list/modifiers/1.h (working copy) @@ -89,14 +89,22 @@ b = list0301.begin(); list0301.insert(b, A, A + N); // should be [321 322 333 13 13] VERIFY(list0301.size() == 5); +#if __cplusplus >= 201103L + VERIFY(copy_constructor::count() == 0); +#else VERIFY(copy_constructor::count() == 3); +#endif VERIFY(m->id() == 13); // range fill at end value_type::reset(); list0301.insert(e, A, A + N); // should be [321 322 333 13 13 321 322 333] VERIFY(list0301.size() == 8); +#if __cplusplus >= 201103L + VERIFY(copy_constructor::count() == 0); +#else VERIFY(copy_constructor::count() == 3); +#endif VERIFY(e == list0301.end()); VERIFY(m->id() == 13); @@ -104,7 +112,11 @@ value_type::reset(); list0301.insert(m, A, A + N); VERIFY(list0301.size() == 11); +#if __cplusplus >= 201103L + VERIFY(copy_constructor::count() == 0); +#else VERIFY(copy_constructor::count() == 3); +#endif VERIFY(e == list0301.end()); VERIFY(m->id() == 13); Index: testsuite/23_containers/list/requirements/dr438/assign_neg.cc =================================================================== --- testsuite/23_containers/list/requirements/dr438/assign_neg.cc (revision 196748) +++ testsuite/23_containers/list/requirements/dr438/assign_neg.cc (working copy) @@ -18,7 +18,7 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1525 } +// { dg-error "no matching" "" { target *-*-* } 1529 } #include