From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by sourceware.org (Postfix) with ESMTPS id 19E843858D3C for ; Fri, 2 Dec 2022 07:23:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 19E843858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-x631.google.com with SMTP id jl24so3877992plb.8 for ; Thu, 01 Dec 2022 23:23:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=tRnPZg5/f1jJ5bOdodF6WqJ8Br3+HcCAwwJj1NikUaU=; b=kRtSbIsZz9EhYm4WZE6SPwOUGIlasMu5eKMAD2/hfGWiy6RTIGLCQ0DIuuldqngiYM Ue8VCzC8TRW1xemr6WcDlhVfvxcBZSqypb2s6O+6Notr2eNG0C9qaMiO9fFgbiuk242u TeAqIy+Iacy0GvpMjqeHaDrCFfeNHV+myjl8DUp7OE1aBEXh+SyQb+mKddRjJh3PIhOu lTDdEZS1g0VDTYkJpjP2RYnmera/pMVwK9Sgr0WthOwpgkrLaEWeY7eQQ6QA8mDyQ5on phNMTmqBdoi2gBsMZw7cz6LscZVEXMKMkNkNyWDSQzNUDQZ/ygQyd67QUgbOC6MRpXMH j7vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=tRnPZg5/f1jJ5bOdodF6WqJ8Br3+HcCAwwJj1NikUaU=; b=PhB2ISABFUXFlFqpmIZzCKwkQQ3cB82j1ecV5ox7qsxqQ4S+6FhRDaxGpvRnl5OAK6 SOtbHscV+ocSfJQKLFqFtJtT4y1Wc/BXi8Iqun3BCC4q108vKWIghf0p4TqJFhxhn3Ex 0n7nIjn5eKek2aR9i+cA4VrWUELOMJtQGOeTO+Sy0yWuWAvjuKkK6EY/7gguyQrh1GJb VLXb0ncHNbj4aEaLY4YsIdhDwInhRxDaJiXWvZ7L3X2R/zNOj6USjsxVq7MJYh47NDKS GU7kH29OBVMTMrktf7gEyfxuV0MFfN63VmbNdlb6GW2dVcgKzZ6zTGubEhOYojUM6DNP Vavw== X-Gm-Message-State: ANoB5plToRzO2VfeqdFhlVjbFatQguM18hwy/lYuLX0RjgdLLckwNHfv rDIYfRG5PZlJJzVq04ZLHWT8N5AtdD9M9ErjHoIRK9oEimQ= X-Google-Smtp-Source: AA0mqf72hWZ7S+Yl4qE+0D89H34g4Oh33b/BdNbEpJ81zuk8BOCHl/4eAepZbqtLTVwBVFDMYSdaAemStHzmM3xuv6s= X-Received: by 2002:a17:902:7087:b0:189:4de4:e71b with SMTP id z7-20020a170902708700b001894de4e71bmr44411355plk.159.1669965790147; Thu, 01 Dec 2022 23:23:10 -0800 (PST) MIME-Version: 1.0 References: <81026ee4-8f45-3d45-57ca-a9abed92c722@126.com> In-Reply-To: From: leon zadorin Date: Fri, 2 Dec 2022 18:22:58 +1100 Message-ID: Subject: Re: which compiler is right (either to compile or to barf)... To: gcc-help Content-Type: multipart/alternative; boundary="000000000000b57b3b05eed335d2" X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --000000000000b57b3b05eed335d2 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Dec 2, 2022 at 6:18 PM leon zadorin wrote: > On Fri, Dec 2, 2022 at 5:37 PM LIU Hao wrote: > >> =E5=9C=A8 2022/12/2 08:17, leon zadorin via Gcc-help =E5=86=99=E9=81=93: >> No, you do not _instantiate_ `J`. The behavior would have been >> undefined if you did. >> `::std::shared_ptr> p;` is fine on itself, because `J` is not >> instantiated. On the other >> hand, `::std::shared_ptr> p(static_cast*>(nullptr));` is >> undefined, as it instantiates a >> delete expression. >> >> >> In addition to that, [temp.point]/1 specifies that the point of >> instantiation of members of a class >> template _follows the end of_ namespace scope of the most enclosing >> specialization. This allows use >> before definition, which is not permitted for non-template classes: >> >> std::shared_ptr ptr( >> (struct foo*) nullptr); // instantiates `delete (struct foo*) >> ___` >> >> struct foo { }; // the line above would have undefined behavior >> without this >> >> >> So, either way, your code is not undefined. >> >> > Wow, ok, many thanks -- veeery interesting :) So I'm getting confused a > little :) > > Let me summarize here: > > (1) On the one hand, given that I do instantiate ::std::optional with S > (whith has member v whose elements' types, I guess(?) are at the line of > declaring 'static ::std::optional s', are still incompletely denifed, > i.e. X) -- the clang discussion appears to say that at this moment option= al > is instantiated and S is incomplete (?) ... as so it is a UB... which I > understood Jonathan's comment to relate to as well. > > (2) However, from your comment it would appear that 'instantiation of > members of class template' is done afterwards anyways... > > I suppose to reconcile both bits of info: > > (a) 'instantitation of members of class template' ... is it the same for > instantitaion of the class template itself? (because UB specs appears to > provide restrictions on std lib class instantiations, not specifically to > inner members, but just for whole class)?; and > > (b) in the above code right at the line 'static ::std::optional s' is S > considered incomplete type at that moment? > > ... I'm just trying to figure out whether template "::std::optional" > is, itself, being instantiated at that very line (never mind its members) > and if type S at that moment is considered to be incomplete... in which > case it is UB... if not then may be its not a UB... I am confused :) ha ha > :) wouldn't be the first time though :) > sorry in the above 'static ::std::optional s' should read 'static ::std::optional opt' of course -- a bloody typo :) --000000000000b57b3b05eed335d2--