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 222C93858C55 for ; Thu, 13 Oct 2022 14:44:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 222C93858C55 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=1665672279; 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=YEOuB/QxaGvwNpvBs4Buv7/d/JSrGcSpbamtN5w7peU=; b=b24gLd65qE4HP+ntflsY7ntgCFNYyaM5im1ZFlDtL0i8bChuhJjMMa7g+dLMO3kHDpASy2 DKjdSIsjGY+MjYagYfyktUoUnYablBNedpILDovWW99Na6gkaojazLEUdyg5hk+nEg1O6A o1B4ppZTeocGHMw3QaO7Q8AI4cdc4lE= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-349-BR6P_lsEP3aVPvDr9-QQ1Q-1; Thu, 13 Oct 2022 10:44:38 -0400 X-MC-Unique: BR6P_lsEP3aVPvDr9-QQ1Q-1 Received: by mail-qv1-f71.google.com with SMTP id t19-20020a056214119300b004b03f58b1abso1472665qvv.17 for ; Thu, 13 Oct 2022 07:44:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YEOuB/QxaGvwNpvBs4Buv7/d/JSrGcSpbamtN5w7peU=; b=uudULRwRXoyo3tGqYFf8iRUmMywewDW5qjcwdT5N4+Wh/yd7Y1jJQO6n3kHGQmPO8l q2f/WJ0Am/1o9RNX7hqAMm4HbcFj5A+8ozcZQl1kwjuT7/tBbE/kiUUIX8rZU/R2IWZG gGj6MeFeFOwmk2ROz8buW/+8RIhLQOhLTVWUniLS/zLT8RthrvbpFLtqTI73DM1Ug9kZ zE5FJGa6irEd9k7pzl/2pZfPamlBTP+hPrGdJlR5W1EDLO+7AeTrjjhWbGwSQcYzm+9g i7c5DcHtMrCa4erdA5VdZgXwZY2llJLlderpEfuujRHf3mO1VhLGNXil3ypJGlopuj3M JcbQ== X-Gm-Message-State: ACrzQf3lJ8wiiogw3ZqQv5812Bq7QwFbbd3T3fyiAhlTwkjr03xMPVMO wa3TQMya+/+SdwXqyebO2tdsJAw6+5rnGOfx3+MbDwpRqArEQsrd54l9N8lEMiGgJ9WiPWjGWyG eJto74jzRCNk8W0VhSQ== X-Received: by 2002:a05:620a:1275:b0:6ee:8f0c:bf0b with SMTP id b21-20020a05620a127500b006ee8f0cbf0bmr167467qkl.451.1665672277566; Thu, 13 Oct 2022 07:44:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6xWixKfuT/ZjfXQpXjjq4RNv74XOYH5jmyvciXS0Ul+GAYeZ/Mr7QPe1VsCXmAOePwVOy8uw== X-Received: by 2002:a05:620a:1275:b0:6ee:8f0c:bf0b with SMTP id b21-20020a05620a127500b006ee8f0cbf0bmr167449qkl.451.1665672277218; Thu, 13 Oct 2022 07:44:37 -0700 (PDT) Received: from [192.168.1.101] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id do37-20020a05620a2b2500b006ea18f550b0sm17859101qkb.48.2022.10.13.07.44.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 13 Oct 2022 07:44:36 -0700 (PDT) Message-ID: <2e648a10-ffd9-de90-f57d-bc9694279094@redhat.com> Date: Thu, 13 Oct 2022 10:44:36 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.2 Subject: Re: [PATCH v2] c++: ICE with VEC_INIT_EXPR and defarg [PR106925] To: Marek Polacek Cc: GCC Patches References: <20221011200003.695682-1-polacek@redhat.com> <778ca670-6623-77f9-e941-51302007da64@redhat.com> From: Jason Merrill In-Reply-To: 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=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,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 10/12/22 14:23, Marek Polacek wrote: > On Wed, Oct 12, 2022 at 01:12:57PM -0400, Marek Polacek wrote: >> On Wed, Oct 12, 2022 at 12:47:21PM -0400, Jason Merrill wrote: >>> On 10/12/22 12:27, Marek Polacek wrote: >>>> On Tue, Oct 11, 2022 at 04:28:11PM -0400, Jason Merrill wrote: >>>>> On 10/11/22 16:00, Marek Polacek wrote: >>>>>> Since r12-8066, in cxx_eval_vec_init we perform expand_vec_init_expr >>>>>> while processing the default argument in this test. >>>>> >>>>> Hmm, why are we calling cxx_eval_vec_init during parsing of the default >>>>> argument? In particular, any expansion that depends on the enclosing >>>>> function context should be deferred until the default arg is used by a call. >>>> >>>> I think this is part of the semantic constraints checking [dcl.fct.default]/5 >>>> talks about, as in, this doesn't compile even though the default argument is >>>> not executed: >>>> >>>> struct S { >>>> S() = delete; >>>> }; >>>> void foo (S = S()) { } >>>> In the test below we parse '= MyVector<1>()' and end up calling mark_used >>>> on the implicit "constexpr MyVector<1>::MyVector() noexcept ()" >>>> ctor. mark_used calls maybe_instantiate_noexcept. Since the ctor has >>>> a DEFERRED_NOEXCEPT, we have to figure out if the ctor should be noexcept >>>> or not using get_defaulted_eh_spec. That means walking the members of >>>> MyVector. Thus we reach >>>> /* Core 1351: If the field has an NSDMI that could throw, the >>>> default constructor is noexcept(false). */ >>> >>> Maybe we need a cp_unevaluated here? The operand of noexcept should be >>> unevaluated. >> >> That wouldn't help since get_nsdmi specifically does "cp_evaluated ev;", >> so... >> >>>> and call get_nsdmi on 'data'. There we digest its initializer which is {}. >>>> massage_init_elt calls digest_init_r on the {} and produces >>>> TARGET_EXPR >>> D.2518 >>>> {} >>>> >>>> and the subsequent fold_non_dependent_init leads to cxx_eval_vec_init >>>> -> expand_vec_init_expr. >>>> >>>> I think this is all correct except that the fold_non_dependent_init is >>>> somewhat questionable to me; do we really have to fold in order to say >>>> if the NSDMI init can throw? Sure, we need to digest the {}, maybe >>>> the field's ctors can throw, but I don't know about the folding. >>> >>> And we can check cp_unevaluated_operand to avoid the >>> fold_non_dependent_init? >> >> ...we'd still fold. I'm not sure if we want a LOOKUP_ flag that says >> "we're just checking if we can throw, don't fold". > > Eh, a new flag is overkill. Maybe don't do cp_evaluated in get_nsdmi if > we're called from walk_field_subobs would be worth a try? It seems that we treat DMI instantiations as evaluated even if they're triggered from unevaluated context so sharing lambdas between different uses of the DMI works properly. I don't think this is worth messing with at this point; thanks for satisfying my curiosity. Jason