From patchwork Mon Dec 4 16:42:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Hawkins X-Patchwork-Id: 81291 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 08FF0385E00F for ; Mon, 4 Dec 2023 16:42:57 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-oo1-xc35.google.com (mail-oo1-xc35.google.com [IPv6:2607:f8b0:4864:20::c35]) by sourceware.org (Postfix) with ESMTPS id DE76B38582AC for ; Mon, 4 Dec 2023 16:42:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DE76B38582AC Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=obs.cr Authentication-Results: sourceware.org; spf=none smtp.mailfrom=obs.cr ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DE76B38582AC Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::c35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701708162; cv=none; b=lQo0Np+AEbCGuRy1Ks+eqB2CQm2HPCPGloO3/mRhws69aU2X+Klc7Xop8ZIm67xCWKI0RG8YcT+sYgf8lbtLK7uqk1y9uvEdg8TuzLsSd05hS8dt7/oent1c9CB/nyGEvr0d594Um2KHt/Jw4yYVNWId663dAQP1X9L3m3hjlY4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701708162; c=relaxed/simple; bh=m567vy7gm2DLKLIDeDa4zmseEPxawybYXGuD2lDQ07U=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=oAEefHl4vqd2/qWO8wYQZ612iP0ZtUn4JneCScr2rQpKgkHabcYQneRMSdoIoGgdw4g9uIxPak0gF5cyjmLo76xe4/PbG4WmGZ+OpKyiQ3PfBMcLi+E9je9GrKHo0C3KxbKRmwo2FLDb9o3P5wbflnB7dbfqtw3x9QcFK+xNsLc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oo1-xc35.google.com with SMTP id 006d021491bc7-58dd3528497so3173241eaf.3 for ; Mon, 04 Dec 2023 08:42:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=obs-cr.20230601.gappssmtp.com; s=20230601; t=1701708160; x=1702312960; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=178LV0NLkYDadeNIga/3qUugyJpQdEBGICVmNynfG50=; b=BQoyE1hZ8oVmLd3oLFKAy7OLTU0IL5CERnJU1UQh1uviie9L09EzC2jekjZtcZMQBY lp9DF3IFOvXuMmsGB20jQtG3gbHZlk32hzfqF951Y8IyJaz7wx0HZo4McUIVp3pnpEv5 Gl3LtcTk8GbaC1Mx0weFw+q70S7S+f+gPLzl710OxA1VFtj+1HbiaXFMC+EvA5Jic9Um Iui0RBwbNnaOctDNQl153WKzcYZm4boSmkUo6Q1PTrPAHdUT25Poy2Ec3AY6sbQbY9dB zlmvRwS+7boPr/WIfPtb8utJL9FqFxFJeo4L6wED7DTzOrRem8crUyRDu2z7RPecitlx rw9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701708160; x=1702312960; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=178LV0NLkYDadeNIga/3qUugyJpQdEBGICVmNynfG50=; b=etVIN3IVeuzmakLFEAgjSFooyCYDlJy+a7yo3dzLaol/xvsCk0xTMWyL6arC144A33 9/peCRxeB3gcV2QTEnLbjVNEt9mpcweJCoNiHP7guGxfWZXlxE/0hf7OZRzTSFPaVVot 6w6n4tacS7GER5Am7i/with6XS3mWu7q8WoIHePiEbxFeaGb3lQZjIww5S9RQY5tQg1M MQpj2sCHBgw0oJanYpy3RA2rab2lYUj5PLlHUNeqUkO0bX/HZn7H01R0H8sG1iEX/q2x cSOkFWnTxkplaq5sKhkzhEaBrb62dT8PRkGRH0O5ctX52FMSBsVNO3W2U4XqO77NCvlQ duCQ== X-Gm-Message-State: AOJu0YymdiT+hLVzQG3KcRSWeGHqHyMIFyK6brEk6e+7HrlmarDrx+Dg dAMACjaThhePnPfqMm1Gh53TxGMr6lDyzOvhoFI= X-Google-Smtp-Source: AGHT+IFeB8efq0rWYuEP2IUIsBseOf90Nh8B7Ma+xAThWuJbLXyoRQEQwez7PHZfFAj5De1nkmIdyw== X-Received: by 2002:a05:6358:50c6:b0:170:17ea:f4db with SMTP id m6-20020a05635850c600b0017017eaf4dbmr4835785rwm.40.1701708159706; Mon, 04 Dec 2023 08:42:39 -0800 (PST) Received: from borderland.rhod.uc.edu ([129.137.96.2]) by smtp.gmail.com with ESMTPSA id t27-20020a0cb39b000000b0067a788e258bsm4473312qve.133.2023.12.04.08.42.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 08:42:39 -0800 (PST) From: Will Hawkins To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Cc: Will Hawkins Subject: [PATCH] libstdc++: Add test for LWG Issue 3897 Date: Mon, 4 Dec 2023 11:42:31 -0500 Message-ID: <20231204164231.784822-1-hawkinsw@obs.cr> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Hello! Thank you, as always, for the great work that you do on libstdc++. The inout_ptr implementation properly handles the issue raised in LWG 3897 but it seems like having an explicit test might be a good idea. I hope that this helps! Will -- >8 -- Add a test to verify that the implementation of inout_ptr is not vulnerable to LWG Issue 3897. libstdc++-v3/ChangeLog: * testsuite/20_util/smartptr.adapt/inout_ptr/3.cc: New test for LWG Issue 3897. Signed-off-by: Will Hawkins --- .../20_util/smartptr.adapt/inout_ptr/3.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 libstdc++-v3/testsuite/20_util/smartptr.adapt/inout_ptr/3.cc diff --git a/libstdc++-v3/testsuite/20_util/smartptr.adapt/inout_ptr/3.cc b/libstdc++-v3/testsuite/20_util/smartptr.adapt/inout_ptr/3.cc new file mode 100644 index 00000000000..f9114dc57b5 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/smartptr.adapt/inout_ptr/3.cc @@ -0,0 +1,17 @@ +// { dg-do run { target c++23 } } + +#include +#include + +// C++23 [inout.ptr.t] Class template inout_ptr_t +// Verify that implementation handles LWG Issue 3897 +void nuller(int **p) { + *p = nullptr; +} + +int main(int, char **) { + int *i = new int{5}; + nuller(std::inout_ptr(i)); + + VERIFY(i == nullptr); +}