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 A1AD03858401 for ; Wed, 3 Apr 2024 17:14:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A1AD03858401 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A1AD03858401 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712164494; cv=none; b=avWZAx18nEJMCcgJW704X5r6VKdGaHrR6RtHPvTFHUxUqrj9E96urzLisXIob1b/6GX30mb7qddX2OYE9yVQBmehCIi6h2I96R2YA4W3psx+87R4Z0XtMrp2SUgaLCMweZgKI1Pg5IDRX9G/P6wb2ASb1G6jxwwXa0IvX07lQ/o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712164494; c=relaxed/simple; bh=kx9nAKUtnW0e03VmYYM0icnuxiIEZenxNFAX8OrsrEg=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=hAMF7nIpCjyM1eylz0L6oIQFY/czFZc2kbYxT2K8qRYmUUgzxQsxgEYIJYrBPRYNgSNq/p0WXMFnRTUK/dXz44CgYzEVaX143T4RrjE8I7NVtuF7LuK3kUWISyIoaHQDvLF0CcZtTpbTg/GO6k7BII4A5fxCYSWJEflMjc/9JnA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712164491; 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: in-reply-to:in-reply-to:references:references; bh=a1pIaIYrlSdWxBPxOiabaD0oSyb5Us2az4LrHGnhpIo=; b=eIv+BQkqMoA9kT/+0BKqkE+uAeSK707O8sdwHgKbN9whyyZyqzguA8T3fZ15P4AgRKmvZk Wo1Y6mI/YfVYSl4COvGga9L6eAZgDOzRodAi0yZynAEdwo8uPIpahgrPY6+6LO0GefX8FY 3hWzdduzLF0rQmIWkIGGNFbjIV9JnIc= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-301-pSC-77JSMMyb6qyQ-FAqtA-1; Wed, 03 Apr 2024 13:14:49 -0400 X-MC-Unique: pSC-77JSMMyb6qyQ-FAqtA-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-6990dbf027dso236736d6.0 for ; Wed, 03 Apr 2024 10:14:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712164489; x=1712769289; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=a1pIaIYrlSdWxBPxOiabaD0oSyb5Us2az4LrHGnhpIo=; b=AAWd8JYarMA8qcS85CknOf2Gss2bC+JsOjJsIOBFMJa9//GOlTT1VSKO0fwE49Wetw H99eUrgOtpGR5qkxienrwdSaAWijuLFsOoAzmUg+3yaZ+cDNEo4nvFL9VPojyjbaurnA soEfOXftLk1ZtlNru5qo2rDxhrXQ179xu5exLDZ5ybhggS2szufEfwh6feDT8UogJa3p nGrR5Oe/aAPJMPQ0MivxTOTxO7+hXN3c264OPzMKD7Ly3/ONvHECrHogzFfvN88jlfhD Z6iwPP3zENvURo1P/GurdKl/T1ulN38pElOwVVyeBuagr+Civ3EnQCxontjj57vGMUUb hlQw== X-Forwarded-Encrypted: i=1; AJvYcCW08n+MzMC76FDdXI73g52d3YIQ133fMbqh2A9W78wOwwlds42cRd+haXl0gaPVCkMcErxcQwUd8u9iEWAcBYZ84ujLxrbNug== X-Gm-Message-State: AOJu0Ywhoh3qPdxIdoINroGh/cUz4F142mSOnu0JGze9lKqw2t6Ko/t+ phNNvQgvZc33bthOWTdQx14VR7lfVOulKXfKLBYQ/QwxvGKL6i1qjW8ZXfeZv5J+aHdfZfEzHcQ V1QBYQCQYbpWHD7O71ka0iz1M4FOIQecJ4Lfqc7ZQSJ2aCjKMTVqSvA4= X-Received: by 2002:ad4:4b6f:0:b0:699:c02:57a9 with SMTP id m15-20020ad44b6f000000b006990c0257a9mr7749135qvx.1.1712164489289; Wed, 03 Apr 2024 10:14:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGYIMMpgdVzkMbR/XdI+M9671uaKB5rKA3gaaocQizlq3S7q0FCYUd5fqQTFVoMxDM4JnaSPg== X-Received: by 2002:ad4:4b6f:0:b0:699:c02:57a9 with SMTP id m15-20020ad44b6f000000b006990c0257a9mr7749120qvx.1.1712164488886; Wed, 03 Apr 2024 10:14:48 -0700 (PDT) Received: from [192.168.1.130] (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id pd8-20020a056214490800b006912014b98dsm1015467qvb.129.2024.04.03.10.14.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 03 Apr 2024 10:14:48 -0700 (PDT) Message-ID: Date: Wed, 3 Apr 2024 13:14:46 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] c++: constexpr error with fn redecl in local scope [PR111132] To: Marek Polacek , GCC Patches Cc: Jakub Jelinek References: <20240402175237.482119-1-polacek@redhat.com> From: Jason Merrill In-Reply-To: <20240402175237.482119-1-polacek@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,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: On 4/2/24 13:52, Marek Polacek wrote: > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk/13? > > -- >8 -- > We evaluate constexpr functions on the original, pre-genericization bodies. > That means that the function body we're evaluating will not have gone > through cp_genericize_r's "Map block scope extern declarations to visible > declarations with the same name and type in outer scopes if any". Here: > > constexpr bool bar() { return true; } // #1 > constexpr bool foo() { > constexpr bool bar(void); // #2 > return bar(); > } > > it means that we: > 1) register_constexpr_fundef (#1) > 2) cp_genericize (#1) > nothing interesting happens > 3) register_constexpr_fundef (foo) > does copy_fn, so we have two copies of the BIND_EXPR > 4) cp_genericize (foo) > this remaps #2 to #1, but only on one copy of the BIND_EXPR > 5) retrieve_constexpr_fundef (foo) > we find it, no problem > 6) retrieve_constexpr_fundef (#2) > and here #2 isn't found in constexpr_fundef_table, because > we're working on the BIND_EXPR copy where #2 wasn't mapped to #1 > so we fail. We've only registered #1. > > It should work to use DECL_LOCAL_DECL_ALIAS (which used to be > extern_decl_map). We evaluate constexpr functions on pre-cp_fold > bodies to avoid diagnostic problems, but the remapping I'm proposing > should not interfere with diagnostics. > > This is not a problem for a global scope redeclaration; there we go > through duplicate_decls which keeps the DECL_UID: > DECL_UID (olddecl) = olddecl_uid; > and DECL_UID is what constexpr_fundef_hasher::hash uses. > > PR c++/111132 > > gcc/cp/ChangeLog: > > * constexpr.cc (get_function_named_in_call): If there's > a DECL_LOCAL_DECL_ALIAS, use it. Perhaps this function should use cp_get_fndecl_from_callee, and this change should be made there instead? Jason