From patchwork Thu Sep 12 15:16:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 274566 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0A5382C03A7 for ; Fri, 13 Sep 2013 01:17:03 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=W4Lf0fEA6fdIHLDBq152CSJJhNpfFK+1q1/SyvCLnVD bXcai0e62yRk5zRtQmO10/5h0cGI9OtSaELY4bu37zzfo9b6+XtueGUJP12XKIGG C0zc7aZZ8LRGWTLLktM0Qqe1QZ47w/tPra/UaDsRTfhGLLwudBGmyH4Uq3KJnBOQ = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=uonSmtyZSJoPiAxVgn4D8+vmbqQ=; b=o8oxfQkMwaFQNDfp+ AWQuPTwjG/SQ/8g2TtF0mbShWFilBkqRk7PGIWG1YkEnIlwqniD+4HuAm/wPw1/D c+B3eVIF/HgVImwdc4dQPx0fL4ZdPqRgEP2DcMrUwZJeLq4n7egcOcLXRpPGEZm9 h5qZq30us3hgzvDzMMri5LXzB8= Received: (qmail 27493 invoked by alias); 12 Sep 2013 15:16:48 -0000 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 Received: (qmail 27472 invoked by uid 89); 12 Sep 2013 15:16:47 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 12 Sep 2013 15:16:47 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.0 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_SOFTFAIL, UNPARSEABLE_RELAY autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: aserp1040.oracle.com Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r8CFGigQ014105 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 12 Sep 2013 15:16:44 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r8CFGhMe016154 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 12 Sep 2013 15:16:43 GMT Received: from abhmt117.oracle.com (abhmt117.oracle.com [141.146.116.69]) by userz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r8CFGgP8023336; Thu, 12 Sep 2013 15:16:42 GMT Received: from poldo4.casa (/79.25.196.6) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 12 Sep 2013 08:16:42 -0700 Message-ID: <5231DAD8.7020800@oracle.com> Date: Thu, 12 Sep 2013 17:16:40 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: libstdc++ Subject: [v3] libstdc++/58403 X-IsSubscribed: yes Hi, see the audit trail for details. Tested x86_64-linux, committed to mainline. Thanks, Paolo. //////////////////////// 2013-09-12 Paolo Carlini PR libstdc++/58403 * include/bits/stl_iterator.h (__normal_iterator<>::operator[], operator+=, operator+, operator-=, operator-): Take the argument by value. * testsuite/24_iterators/normal_iterator/58403.cc: New. Index: include/bits/stl_iterator.h =================================================================== --- include/bits/stl_iterator.h (revision 202517) +++ include/bits/stl_iterator.h (working copy) @@ -783,23 +783,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Random access iterator requirements reference - operator[](const difference_type& __n) const + operator[](difference_type __n) const { return _M_current[__n]; } __normal_iterator& - operator+=(const difference_type& __n) + operator+=(difference_type __n) { _M_current += __n; return *this; } __normal_iterator - operator+(const difference_type& __n) const + operator+(difference_type __n) const { return __normal_iterator(_M_current + __n); } __normal_iterator& - operator-=(const difference_type& __n) + operator-=(difference_type __n) { _M_current -= __n; return *this; } __normal_iterator - operator-(const difference_type& __n) const + operator-(difference_type __n) const { return __normal_iterator(_M_current - __n); } const _Iterator& Index: testsuite/24_iterators/normal_iterator/58403.cc =================================================================== --- testsuite/24_iterators/normal_iterator/58403.cc (revision 0) +++ testsuite/24_iterators/normal_iterator/58403.cc (working copy) @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++11" } +// { dg-do link } + +// 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 +#include + +struct A { + static constexpr std::iterator_traits< + std::string::iterator>::difference_type a = 1; +}; + +int main() +{ + std::string s = "foo"; + auto it = s.begin(); + it += A::a; +}