From patchwork Fri Jun 21 10:05:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 253170 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 CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id AFFD32C0302 for ; Fri, 21 Jun 2013 20:05:54 +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=IxPDMeCLFrXRnle2VGwsK8M8vrE/2LI4+XdyTWAODws 5ZZ1G8kmwwdr8tUKZn93qsrLt/Z2XU58DUo6lDD2TWDKpEkAiFF8gPyTxNbWWXHF cWjI1hb12fP7RRVT788DA0Mxw4h9IxAxwkPPG8Ug/6sJtfGB/yvVkQ6Q5lCvZ6uQ = 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=y3R4oi6NxkIBEGZb1IbmrZFjkcM=; b=q1Aj4QjeZ66w7+D3y baUHioWJGbNSqNBLLXQJpnMcj5rw4Xzl/lFOIlbbfCNo6wYlymf0mhNn3dR+40ac m2mEdcuAg0bVPgXy3QeYxQIgC85CJ7em7ycfU0wZ5o4kg+9WGEMQdHDgn0NaWZgX 1BcGYx+Zn9XdTbStdD6Q3TH96I= Received: (qmail 13130 invoked by alias); 21 Jun 2013 10:05:47 -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 13115 invoked by uid 89); 21 Jun 2013 10:05:46 -0000 X-Spam-SWARE-Status: No, score=-6.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, SPF_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-User: qpsmtpd, 2 recipients Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 21 Jun 2013 10:05:45 +0000 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 r5LA5gMP010031 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 21 Jun 2013 10:05:42 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r5LA5fXH010403 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 21 Jun 2013 10:05:42 GMT Received: from abhmt106.oracle.com (abhmt106.oracle.com [141.146.116.58]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r5LA5ehu000286; Fri, 21 Jun 2013 10:05:40 GMT Received: from poldo4.casa (/79.33.220.218) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 21 Jun 2013 03:05:40 -0700 Message-ID: <51C42572.7080503@oracle.com> Date: Fri, 21 Jun 2013 12:05:38 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 MIME-Version: 1.0 To: libstdc++ CC: "gcc-patches@gcc.gnu.org" , Gabriel Dos Reis Subject: [v3] libstdc++/57666 X-Virus-Found: No Hi, looks like we implemented LWG 630 incompletely, not updating: valarray<>::operator=(const _Expr<>&) together with the copy assignment operator. The inconsistency clearly shows up eg when we try to assign the result of an arithmetic binary operation. Tested x86_64-linux. Gaby, any issues? Thanks, Paolo. ////////////////// 2013-06-21 Paolo Carlini PR libstdc++/57666 * include/std/valarray (valarray<>::operator=(const _Expr<>&)): Implement correctly C++11 26.6.2.3/1. * testsuite/26_numerics/valarray/dr630-3.C: New. Index: include/std/valarray =================================================================== --- include/std/valarray (revision 200268) +++ include/std/valarray (working copy) @@ -819,8 +819,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline valarray<_Tp>& valarray<_Tp>::operator=(const _Expr<_Dom, _Tp>& __e) { - _GLIBCXX_DEBUG_ASSERT(_M_size == __e.size()); - std::__valarray_copy(__e, _M_size, _Array<_Tp>(_M_data)); + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 630. arrays of valarray. + if (_M_size == __e.size()) + std::__valarray_copy(__e, _M_size, _Array<_Tp>(_M_data)); + else + { + if (_M_data) + { + std::__valarray_destroy_elements(_M_data, _M_data + _M_size); + std::__valarray_release_memory(_M_data); + } + _M_size = __e.size(); + _M_data = __valarray_get_storage<_Tp>(_M_size); + std::__valarray_copy_construct(__e, _M_size, _Array<_Tp>(_M_data)); + } return *this; } Index: testsuite/26_numerics/valarray/dr630-3.C =================================================================== --- testsuite/26_numerics/valarray/dr630-3.C (revision 0) +++ testsuite/26_numerics/valarray/dr630-3.C (working copy) @@ -0,0 +1,37 @@ +// 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 + +// libstdc++/57666 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::valarray a(3), b(3), d; + d = a; + VERIFY( d.size() == 3 ); + d = a + b; + VERIFY( d.size() == 3 ); +} + +int main() +{ + test01(); + return 0; +}