From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by sourceware.org (Postfix) with ESMTPS id 4883D3858C3A for ; Thu, 1 Dec 2022 23:27:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4883D3858C3A 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-pj1-x1032.google.com with SMTP id 3-20020a17090a098300b00219041dcbe9so3591159pjo.3 for ; Thu, 01 Dec 2022 15:27:02 -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=pXohT44Hk9R1i9HGEtJvsGvCax9l80UctAGddqwmMUo=; b=l2sZ57bZ0RoAR6AOppsbZ83EGm8EkrXMfKhOvOdx5f+IaKxGUpSsgYMqQ5ynjZWGtT xpULqqyJh7nxeD6lIImLypZ+Njn8aJigL+BbXtX/5BJCVikJgkTTT3BI8R7xJMV2WvvU gGmazv6dWqBuFWeIl0YamI37BUL/M90c5HjMp003Fp0kZfH1D3t133okRGkIObq4h5BZ Jzwt7O9STDp7m3uuGDIIp8SGrhx+u36BgQiahIv0t/4OQdNj3onVgx9qF4JADDkHi5Yb w+YBYoqlBpFjq791tnFQix6mQGSM9vCGhdrJk69lYYp3fEvmSP9GLfGpF94YbHSMzXbA I6Vw== 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=pXohT44Hk9R1i9HGEtJvsGvCax9l80UctAGddqwmMUo=; b=DD1REf2ftI6z+RJWDU2kgssplY/mmWF0dXjj5WvwI+3qjygHCWeT9JyyUMRUs9Bxft sZpRxsd5dainVjjTMvgEMNrjrYyqs2TgT+X0UJeETtpY3eg2TT3W/NSFmD59kuZPMvKz KGSXziUecFugE3qIo4V4vdmUph4GVsdM216v/inbf1aZAFzIlxzwb9ve4ogWPC5WWlGt SS5uKtcmVdkFDz1Zx/zFQ0WUkL0s9zunSvfDJ1MWAbkZL/SBZvDkha4LOvkEMSv/p2nG IbhTZd6/N0MRHHyWJee3TjMg0ANnZAsq/JpLFeOg3r6BUQ+p9ZfJAp12OVGKHE94wGiN 3IRg== X-Gm-Message-State: ANoB5pl+ezHgNKBGi51su95tV10eu3ALpvprjXhMN+Hw4vtnSY+izkTj 2E/V8+8kUdI+WQskiZapV18tSdcY5KBiEjAmmDe1f8Bkhb8= X-Google-Smtp-Source: AA0mqf4pYKgLvMbrfOGQ8Ti/+e/Lme9T4oMhYwGDi4kmKE9Dntk71mjSnNMSvF5dY+nMl+9UHJEqBWNW73+h9dMDCoI= X-Received: by 2002:a17:90a:2b44:b0:213:d66b:4973 with SMTP id y4-20020a17090a2b4400b00213d66b4973mr79185829pjc.85.1669937221059; Thu, 01 Dec 2022 15:27:01 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: leon zadorin Date: Fri, 2 Dec 2022 10:26:49 +1100 Message-ID: Subject: Re: which compiler is right (either to compile or to barf)... To: gcc-help Content-Type: multipart/alternative; boundary="000000000000dbcc8605eecc8ecb" X-Spam-Status: No, score=-0.1 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: --000000000000dbcc8605eecc8ecb Content-Type: text/plain; charset="UTF-8" On Thu, Dec 1, 2022 at 8:35 PM LIU Hao wrote: > > I think this is a bug in Clang. Instantiation of `shared_ptr>` is not > meant to instantiate > `T`. Your code actually compiles fine if the definition of `J` was not > provided. > > -- > Best regards, > LIU Hao > Thanks :) It is rather interesting, there is a discussion at https://github.com/llvm/llvm-project/issues/59292 which may be pointing to implementation differences between stdlibc++ and libc++ etc. There is thinknig that it just may be UB in the originally-posted code (if so then clang is rather helpful there, but only when used with libstdc++ apparently.. as I haven't personally verified the delta between building against different libs :) :) ) The current thought prorcess is that std component must be allowed by the standard to be instantiated with incomplete type T. And vector is allowed so indeed (but I think it must be complete by the time its members, e.g. via member-function invocation, are referenced)... so then it may come down to std::optional and its implementation -- whether its ctor is referencing any vector's members (dtor etc.) ... I suppose the official way would be to find whether ::std::optional may be instantiated with incomplete type T (say even if only when using default, no value present, ctor overload)... and if it not mentioned of being able to do so then it would be a bug in the original code (at which point having some toolchain being able to detect it is rather super nice :) :) I dont know to be honest if standard's doco for such ctor , e.g. constexpr optional() noexcept; constexpr optional(nullopt_t) noexcept; Postconditions: *this does not contain a value. Remarks: No contained value is initialized. For every object type T these constructors are constexpr constructors would be sufficient to infer the ability to instantiate with incomplete type... probably not (I'm not enough of an expert to see through this with my cloudy head atm :) --000000000000dbcc8605eecc8ecb--