From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by sourceware.org (Postfix) with ESMTPS id 14D7A3858D35 for ; Mon, 13 Sep 2021 08:52:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 14D7A3858D35 Received: by mail-wr1-x432.google.com with SMTP id d6so13386640wrc.11 for ; Mon, 13 Sep 2021 01:52:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=XjWW7YXOMUxQTpQxw6I1WGIfXe2WGFFQFOSUealWMD4=; b=5OJSLyL50JTLv7vQXGXd0ikEFNGejnniZwdjngRUIlU4SRfmsHxBN25nKEHt/Hick/ 1/2VyO9IU+qG5uIjDAsIIS1hsrIZxI7UoD8sfeafAHFPY80YGLSUXgxhsmkWdx5UG207 rNYzGmlqL/K1Brwn0htFCrGHiL45N7Tav4lQ7qkkF9mrdSehWLgYfUF8+RL155Bz3e3d 1DeEU93Jsw8XcU+M6HB7cg8g/qxIAUbsw58kJnGf+CLBkRYxEO9Z6kE0RSHsIaOR3vZc C+E4ZjFWxKJPx7oWfeyJwAucOX/S6/DBDLTItdUWOEnzIfr0ZBFwMuZGlqKeY5Q0bFhy TUkw== X-Gm-Message-State: AOAM533eqjW+FZGzpkRjKdzWC6WjVIL1vHpVL+49ZiQwajLOI9c7ZivB EqvcvPwNBo4TKPnMtjdhBOBJ810SgcXk74+3cUE= X-Google-Smtp-Source: ABdhPJxOQKpHIDkwR7yiulsOzg0ICyh9Vnv+4AI2OLnL/EqS6DT8K8SW2NmnSdBpHsKgbkjhQFpTWXkHkI5iGV/SErU= X-Received: by 2002:a5d:6dd0:: with SMTP id d16mr11014314wrz.177.1631523147061; Mon, 13 Sep 2021 01:52:27 -0700 (PDT) MIME-Version: 1.0 References: <63CE1E9B-77D5-4E17-95FA-554B45C4028D@globus.software> <7E360609-1A07-4A41-8775-6CD46D382067@globus.software> In-Reply-To: <7E360609-1A07-4A41-8775-6CD46D382067@globus.software> From: Jonathan Wakely Date: Mon, 13 Sep 2021 09:52:15 +0100 Message-ID: Subject: Re: Forward declaration and std::future To: Evgen Bodunov Cc: "libstdc++" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: Mon, 13 Sep 2021 08:52:29 -0000 On Mon, 13 Sept 2021 at 09:33, Evgen Bodunov wrote: > > > On 12.09.2021, at 22:04, Jonathan Wakely via Libstdc++ wrote: > > > > On Sun, 12 Sep 2021, 19:30 Evgen Bodunov, wrote: > >> > >> Please, could you refer exact part and version of the standard? > >> > > > > Please reply to the mailing list, not just to me. > > > > Every version of the standard has the same requirement, see > > http://eel.is/c++draft/requirements#res.on.functions-2.5 > > > > std::promise requires its result type to be destructible. We are allowed to > > assert that by using is_destructible because we can assume the type is > > complete, because [res.on.functions] says it must be. > > > > In a correct program, the assertion will not fail. > > Thank you for the detailed response. For some reason I expected that if there is not enough > type data to compile the code correctly, there would be an error from the compiler, not from > static_assert. As for example in case of inheritance or creating objects from a type that was > forward declared. And in this case there is an error saying that the class doesn't have a > destructor, although it actually exists and this is confusing. The relevant errors are: error: static assertion failed: template argument must be a complete class or an unbounded array error: static assertion failed: result type must be destructible Neither of these says there is no destructor. It says the type is incomplete, and not destructible. You cannot tell if a type is destructible if it's incomplete, because you can't tell if it has a deleted or private/protected destructor, because it's incomplete.