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 [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 1F9023858C62 for ; Thu, 3 Nov 2022 12:34:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1F9023858C62 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667478842; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=t1V23dHJEnQ8Xvg9P79jZ8MCG2RoeOK59stJkXlLDjg=; b=To74BOlcQx+wWKMWTESgud4JdEcjBy0w3ZS9hvQRmHVa87pEzsP9D1FpmfHXDCvTH5y5qH 5O9363BXCqn0rIk4xV7ziko2D+ubj9DmLdWdP4fx/jC9oWgRABUUA2eKRan88bhUY9z6iM LJZKep4fis86iHcxb2MOvwjl44Xblec= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-482-RAR44OpkNguFU_Pb8gI3jA-1; Thu, 03 Nov 2022 08:33:44 -0400 X-MC-Unique: RAR44OpkNguFU_Pb8gI3jA-1 Received: by mail-qk1-f199.google.com with SMTP id u6-20020a05620a430600b006e47fa02576so1787118qko.22 for ; Thu, 03 Nov 2022 05:33:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=t1V23dHJEnQ8Xvg9P79jZ8MCG2RoeOK59stJkXlLDjg=; b=nuM9ceE/YMGAzxRWs+1df8k4UJZELEJlP336uuFaJtzbfRw7bK6rEr4VtIfHC0ZP2C ALRDCPSSKNwiL3/tvYJD7zzCsAX4zczGMNEbaRom+JJ98dhG6UdwPgESB75cyN8XLkZ3 Z9AafJxQAia2lg+2eV6Q5TDJlFaerNbFgNYX+TvgGHzIBGD2/w2c5KFzNv34Icm9ccyj 4ilZcrMijhSSeLyXgduEP9d6nwuvT/4Uem41bfhWKPF+urssduBpGrSi4EGoqGoeOZt+ tg1sG4v+2NYlc8lXuayfB9IEXFnbmtRIDVnbyfzmZssdFkCM+NCz3rCJMOqIkDc2iCqt coLw== X-Gm-Message-State: ACrzQf32iq8oJDft82jjHSknqSzywVzFMPyOq0f6tbGFK9v8iTxlzGf0 Qidb8r67yeCu7AsUVbzO3K8X7j9VRuk84khRkUoFmjmGCBff8A6lD5zPVsXfczS2a1zKbpychFc 9kIboTI53snRcD6O4FUfWRa8Vc0EWtzwSltfifWd5bb905HcXrtFbmTmzMtQaHJ8j96M= X-Received: by 2002:a05:6214:2342:b0:473:e142:f758 with SMTP id hu2-20020a056214234200b00473e142f758mr26540295qvb.83.1667478823267; Thu, 03 Nov 2022 05:33:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4ahpUVeHsW46a718S2lk+KqR0Fjn6fCa/Grhnz8VKXfbXaw9l5aIWMnJLYTEYNYiWyOE5/NQ== X-Received: by 2002:a05:6214:2342:b0:473:e142:f758 with SMTP id hu2-20020a056214234200b00473e142f758mr26540268qvb.83.1667478822987; Thu, 03 Nov 2022 05:33:42 -0700 (PDT) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id cc9-20020a05622a410900b0039442ee69c5sm416862qtb.91.2022.11.03.05.33.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 05:33:42 -0700 (PDT) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] c++: constexpr error with defaulted virtual dtor [PR93413] Date: Thu, 3 Nov 2022 08:33:40 -0400 Message-Id: <20221103123340.1402161-1-ppalka@redhat.com> X-Mailer: git-send-email 2.38.1.381.gc03801e19c MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-14.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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: We're rejecting the below testcase with error: 'virtual constexpr Base::~Base()' used before its definition error: 'virtual constexpr Derived::~Derived()' used before its definition due to an early exit added to mark_used by r181272 to defer synthesis of virtual destructors until EOF where we can set their linkage. This makes them effectively unusable for constexpr evaluation since that needs to be done immediately and can't also be deferred. Fortunately, this early exit seems to no longer be necessary ever since r208030 enabled us to tentatively set linkage of all defaulted virtual destructors, including templated ones. So this patch just gets rid of this early exit. Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk? PR c++/93413 gcc/cp/ChangeLog: * decl2.cc (mark_used): Don't defer synthesis of virtual functions. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/constexpr-virtual21.C: New test. --- gcc/cp/decl2.cc | 8 -------- gcc/testsuite/g++.dg/cpp2a/constexpr-virtual21.C | 10 ++++++++++ 2 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/constexpr-virtual21.C diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc index e6779268ad4..eeb59eae64f 100644 --- a/gcc/cp/decl2.cc +++ b/gcc/cp/decl2.cc @@ -5788,14 +5788,6 @@ mark_used (tree decl, tsubst_flags_t complain /* = tf_warning_or_error */) && !DECL_DEFAULTED_OUTSIDE_CLASS_P (decl) && ! DECL_INITIAL (decl)) { - /* Defer virtual destructors so that thunks get the right - linkage. */ - if (DECL_VIRTUAL_P (decl) && !at_eof) - { - note_vague_linkage_fn (decl); - return true; - } - /* Remember the current location for a function we will end up synthesizing. Then we can inform the user where it was required in the case of error. */ diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-virtual21.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-virtual21.C new file mode 100644 index 00000000000..8b70c5f538b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-virtual21.C @@ -0,0 +1,10 @@ +// PR c++/93413 +// { dg-do compile { target c++20 } } + +struct Base { + virtual ~Base() = default; +}; +constexpr Base b; + +struct Derived : Base { }; +constexpr Derived d; -- 2.38.1.381.gc03801e19c