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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 74142385382A for ; Thu, 24 Jun 2021 18:53:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 74142385382A Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-465-2o-sezVHMEaVKa4TzTxXNw-1; Thu, 24 Jun 2021 14:53:57 -0400 X-MC-Unique: 2o-sezVHMEaVKa4TzTxXNw-1 Received: by mail-qv1-f72.google.com with SMTP id r15-20020a0562140c4fb0290262f40bf4bcso7977446qvj.11 for ; Thu, 24 Jun 2021 11:53:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:mime-version; bh=E58Qn7mUsl3jHFrmyjarmSbOElrV5u5Zw8yRlUdI0MA=; b=f1us5/MxUvu6at5YKjeZJ4eZeBvixQe3zhB4XdXS7H3xjN7K2COgJznXHAk8+sX4Q7 XEEiwVoy/Ub6OD88mJlQL7hqwRCCU4GpCX+fY19T5GM7NtlBJEHqpeIY3diqIblPjd1b K4FyI5sKCKrXYzL6i5QYOEDPsIhqYaXJuc+eOzqUR7JyuPzRFsFToWg/TQmd1EiyAUNB 5mEktNANCMnZXGXn9nlAuk7npQn2Et4v53dH4Fw290fA7iFClE6aT4vOZQyEFTWaq4jD 7V5SFuG+8HtqPIScIPwbQKhNRmkDpvEBPgbgb7AaKHR5Vd8Vj8hT8LXvt21Y3cJB0vTH E5eA== X-Gm-Message-State: AOAM533+UrBEUaCBneakDqVk8GfPypsn1xmARrDoGZXLfAB15M8BHAYt SRkjNT6M8qkMYqST1ExHkKPNHMNvYmohErS4gh1VrMaTh25lOpPiay+oJvK2qmdNpXtjmlYLmeE 4LwvYnz5z8H9Er+0= X-Received: by 2002:a37:a1cf:: with SMTP id k198mr7166370qke.409.1624560836876; Thu, 24 Jun 2021 11:53:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvyAHMDVBTL4J+p260yhjF/knnFgfIx/OO0HBbRUdM/KXTnzjxwdCf566BYDp+vng373FFgw== X-Received: by 2002:a37:a1cf:: with SMTP id k198mr7166355qke.409.1624560836715; Thu, 24 Jun 2021 11:53:56 -0700 (PDT) Received: from [192.168.1.130] (ool-457d493a.dyn.optonline.net. [69.125.73.58]) by smtp.gmail.com with ESMTPSA id k19sm3160617qkj.89.2021.06.24.11.53.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jun 2021 11:53:56 -0700 (PDT) From: Patrick Palka X-Google-Original-From: Patrick Palka Date: Thu, 24 Jun 2021 14:53:55 -0400 (EDT) To: Jonathan Wakely cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: [committed] libstdc++: Implement LWG 2762 for std::unique_ptr::operator* In-Reply-To: Message-ID: <82f170be-4968-cae2-f775-c863096b5f@idea> References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org Content-Type: text/plain; charset=ISO-8859-7 Content-Transfer-Encoding: 8BIT X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jun 2021 18:54:01 -0000 On Thu, 24 Jun 2021, Jonathan Wakely via Libstdc++ wrote: > The LWG issue proposes to add a conditional noexcept-specifier to > std::unique_ptr's dereference operator. The issue is currently in > Tentatively Ready status, but even if it isn't voted into the draft, we > can do it as a conforming extensions. This commit also adds a similar > noexcept-specifier to operator[] for the unique_ptr partial > specialization. The conditional noexcept added to unique_ptr::operator[] seems to break the case where T is complete only after the fact: struct T; extern std::unique_ptr p; auto& t = p[1]; struct T { }; /include/c++/12.0.0/bits/unique_ptr.h: In instantiation of ˇtypename std::add_lvalue_reference<_Tp>::type std::unique_ptr<_Tp [], _Dp>::operator[](std::size_t) co nst [with _Tp = A; _Dp = std::default_delete; typename std::add_lvalue_reference<_Tp>::type = A&; std::size_t = long unsigned int]˘: testcase.cc:5:14: required from here /include/c++/12.0.0/bits/unique_ptr.h:658:48: error: invalid use of incomplete type ˇstruct A˘ 658 | noexcept(noexcept(std::declval()[std::declval()])) | ~~~~~~~~~~~~~~~~~~~~~~~^ testcase.cc:3:8: note: forward declaration of ˇstruct A˘ 3 | struct A; | ^ > > Also ensure that all dereference operators for shared_ptr are noexcept, > and adds tests for the std::optional accessors modified by the issue, > which were already noexcept in our implementation. > > Signed-off-by: Jonathan Wakely > > libstdc++-v3/ChangeLog: > > * include/bits/shared_ptr_base.h (__shared_ptr_access::operator[]): > Add noexcept. > * include/bits/unique_ptr.h (unique_ptr::operator*): Add > conditional noexcept as per LWG 2762. > * testsuite/20_util/shared_ptr/observers/array.cc: Check that > dereferencing cannot throw. > * testsuite/20_util/shared_ptr/observers/get.cc: Likewise. > * testsuite/20_util/optional/observers/lwg2762.cc: New test. > * testsuite/20_util/unique_ptr/lwg2762.cc: New test. > > Tested powerpc64le-linux. Committed to trunk. > >