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 [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 201DF3857BBC for ; Fri, 2 Feb 2024 10:28:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 201DF3857BBC Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 201DF3857BBC Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706869737; cv=none; b=ikQcqEpstUgejq5mI1z5ETM4pMPWq+Zce1EZyignrcfadx9jjy+Pg/bjwW8mpDO/doP/A6WpDvrvFW+SJBWR4sBMuUM+A7EJ2cY+WvdJfuUiaKQpE7A9ewdKxKxdDpi+eKXUsJCISQoYNYHESOgX60XA1G5KoFja18ZC+igyLUo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706869737; c=relaxed/simple; bh=28a/YkCyVFrtyuxqGMW7R8wnVTC/QUobNC8E+01IXkw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=UdwBUUgWVQQqLeY4pwoerBWVCrRy+Pn6dbGiBQHLfUqplxYJ0KRoY292hY3S2pujIU5ZtOCjdb7Sd0vvzK6s3deJFn79EFTTNWk3OgaWAEUGCAZkdoy5vAalSmx2VGkEsOsnI1CSTIqKY5Xy0VER3L8XQ3f1vqghg3EDvM6iogw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706869734; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ciJ0PZlhVNYPKjjvhVy5ABGlifkRol2CQD9fFR8EauI=; b=YZQgENlz96u7q0NUQwijLVFX6UZjKeAIyBERzqcXmFaQhosj2INxm7dX0gvRuh+nCUzNVF S++gvm7ZPC+JGJuFHcYyQJLbupw0JC/KTF9SX2Ob8ii+Y05aRJ+3jPoKV/TGv5TlDDiHxI BBrfgCOiw7PY8YPZaekfw3eaO680bCE= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-433-NEIXKqgAPcuvKozeSrDbFw-1; Fri, 02 Feb 2024 05:28:51 -0500 X-MC-Unique: NEIXKqgAPcuvKozeSrDbFw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 421863806702; Fri, 2 Feb 2024 10:28:51 +0000 (UTC) Received: from localhost (unknown [10.42.28.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F3781C060B1; Fri, 2 Feb 2024 10:28:50 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Cc: =?UTF-8?q?Fran=C3=A7ois=20Dumont?= Subject: [committed 1/2] libstdc++: Avoid reusing moved-from iterators in PSTL tests [PR90276] Date: Fri, 2 Feb 2024 10:28:07 +0000 Message-ID: <20240202102846.2241323-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Tested x86_64-linux. Pushed to trunk. -- >8 -- The reverse_invoker utility for PSTL tests uses forwarding references for all parameters, but some of those parameters get forwarded to move constructors which then leave the objects in a moved-from state. When the parameters are forwarded a second time that results in making new copies of moved-from iterators. For libstdc++ debug mode iterators, the moved-from state is singular, which means copying them will abort at runtime. The fix is to make copies of iterator arguments instead of forwarding them. The callers of reverse_invoker::operator() also forward the iterators multiple times, but that's OK because reverse_invoker accepts them by forwarding reference but then breaks the chain of forwarding and copies them as lvalues. libstdc++-v3/ChangeLog: PR libstdc++/90276 * testsuite/util/pstl/test_utils.h (reverse_invoker): Do not use perfect forwarding for iterator arguments. --- libstdc++-v3/testsuite/util/pstl/test_utils.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libstdc++-v3/testsuite/util/pstl/test_utils.h b/libstdc++-v3/testsuite/util/pstl/test_utils.h index ed6d48b9471..e35084eabb2 100644 --- a/libstdc++-v3/testsuite/util/pstl/test_utils.h +++ b/libstdc++-v3/testsuite/util/pstl/test_utils.h @@ -1083,18 +1083,18 @@ struct iterator_invoker template struct reverse_invoker { - template + template void - operator()(Rest&&... rest) + operator()(Policy&& exec, Op op, Rest&&... rest) { // Random-access iterator - iterator_invoker()(std::forward(rest)...); + iterator_invoker()(std::forward(exec), op, rest...); // Forward iterator - iterator_invoker()(std::forward(rest)...); + iterator_invoker()(std::forward(exec), op, rest...); // Bidirectional iterator - iterator_invoker()(std::forward(rest)...); + iterator_invoker()(std::forward(exec), op, rest...); } }; -- 2.43.0