From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id 77C1B3858D34 for ; Sun, 12 Sep 2021 18:19:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 77C1B3858D34 Received: by mail-wr1-x42d.google.com with SMTP id u15so4996043wru.6 for ; Sun, 12 Sep 2021 11:19:24 -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=giIm6bQm43DxCyESQ4cY9h4Vyiw6JvDctmdaTEZZAbs=; b=IIoS6PPTqLn6RG6v3HFUC40ZxmEXxAdohKLYVATN3Ai+s01VTCYf99M4vWbSyUGARu NI80NJy84EfF7Xz5AIakNh6u4MukT+Klb6S8ougcYgC6neC4tHNvyva/nW8B67VNj+Hj KbpSDtbauqNz9VSu18IS3ET77nrD8y8xBZ6Iv2VLTSyAMyHas/HySZH6/xt8VRcyNvCN 9K9vMdmrcI7p9D5f/bl+23572px1fe22wEpqCKok5CI0PnEh2n/0vufi9z9/ure1y0Tn gYpTcYnEpIB+jg4C3Yqr0ddKhl+gShn+EeQ0mi5o8+b8A9BVVDZ+DqHeVO5azUz81VOa HTsg== X-Gm-Message-State: AOAM530jaTz4bJVSX0GqXWpl5voayk2CJIJXPioILa6yH9+7b9ZgX88x KtTnV0drkaIdSbkVsIReYcmNx+wNecjuyBavYhY= X-Google-Smtp-Source: ABdhPJxsCodKYNuZ8rrqUq+jrZNVxm9+YwnJzPH7srOEceQpNR13goyfV6atz6CJfjuQ8ZDMXQNqk6OWWfOhJhdeasg= X-Received: by 2002:adf:d1b2:: with SMTP id w18mr8863691wrc.6.1631470763492; Sun, 12 Sep 2021 11:19:23 -0700 (PDT) MIME-Version: 1.0 References: <63CE1E9B-77D5-4E17-95FA-554B45C4028D@globus.software> In-Reply-To: <63CE1E9B-77D5-4E17-95FA-554B45C4028D@globus.software> From: Jonathan Wakely Date: Sun, 12 Sep 2021 19:19:11 +0100 Message-ID: Subject: Re: Forward declaration and std::future To: Evgen Bodunov Cc: "libstdc++" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, 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 Content-Type: text/plain; charset="UTF-8" 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: Sun, 12 Sep 2021 18:19:26 -0000 On Sun, 12 Sep 2021, 10:36 Evgen Bodunov, wrote: > Hello everyone, > > During development of valhalla routing project I stumbled upon compilation > error on gcc + libstdc++ 11 and newer when std::future constructed from > forward declared class. Live example is there: > https://godbolt.org/z/rEx3Eonsz It builds on gcc prior to v11. and on any > clang with libc++. > > /opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/type_traits: In > instantiation of 'struct std::is_destructible': > /opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/future:1065:21: > required from 'class std::promise' > :8:29: required from here > /opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/type_traits:849:52: > error: static assertion failed: template argument must be a complete class > or an unbounded array > 849 | > static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), > | > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ > /opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/type_traits:849:52: > note: 'std::__is_complete_or_unbounded > >((std::__type_identity{}, std::__type_identity()))' > evaluates to false > In file included from :1: > /opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/future: In > instantiation of 'class std::promise': > :8:29: required from here > /opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/future:1065:21: > error: static assertion failed: result type must be destructible > 1065 | static_assert(is_destructible<_Res>{}, > | ^~~~~~~~~~~~~~~~~~~~~~~ > /opt/compiler-explorer/gcc-11.1.0/include/c++/11.1.0/future:1065:21: note: > 'std::is_destructible{}' evaluates to false > Compiler returned: 1 > > Is that static assert is really required? May be then it should correctly > process forward declared types? > The standard says your code has undefined behaviour. The assertion is pointing out your mistake.