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 0CF473858D20 for ; Wed, 30 Aug 2023 20:28:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0CF473858D20 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=1693427302; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dVRavIunCmvJuNR/JVjrqo3mT5xsFaRM0xzmhSFhrXc=; b=YFSwGheuSbVyTDHxkFdrRGluQLO6/34C36OTEiNQEcERwW59+290fbVjN9w3ikMTFbpx9q RMh41r4melUEva0GPYsEXjmtJI741aZ/dP/ROjrOZJgjCuOP98ed0cW/hJzrSqEjuKBiH4 QheL+CwiZNU7dDrdO0KxYu7/vbSF1mg= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-539-kqb-MTn7NZu6fHt-7a9ScQ-1; Wed, 30 Aug 2023 16:28:20 -0400 X-MC-Unique: kqb-MTn7NZu6fHt-7a9ScQ-1 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-4108d23b401so1113051cf.1 for ; Wed, 30 Aug 2023 13:28:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693427300; x=1694032100; h=content-transfer-encoding:in-reply-to:content-language:references :to:subject:from:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dVRavIunCmvJuNR/JVjrqo3mT5xsFaRM0xzmhSFhrXc=; b=krSA6N68XfaisH8O60J2taGK+nZn9Ky74PfcqZ62J/M8kcva81qVHYtdlmmmOhx7Ii fdK/Zy9seM7sVTmb6WxMP+F9TmNqCE8yVvhum3l2pfv8OPNZcSJuiKXW5tTc57fLgpkD GoyoX+u8dpCSjsE7b1ezBN+vVWWdyHuqbbWgZ5JqyOLz2qT6Ib56cHMA3HSjWJ9o3aRK syim3eo8PbNGGZTU22dnkTHN4GIiZlWmgqu+70b53CQkYkhJ+N691XZZfBVQx8J/K+5G KQhe33fikGVP6kmRlZOxmi+HlNsYUamXRpOrKQaY5III/9mUkSG8krLKZpWIYLzFYPEW LbFg== X-Gm-Message-State: AOJu0YxY9GtZlf9ABjA6EvKO1hRkHsOZ9L354zDeooe1i3ZyRk1ZW5cx YUYCi5r3BwAMmwtyZM6hEMhyjR3qCjMoqO79Ev1NJxFgHikb4Rxe+ksNMJv/fH3VnJj0G+vjdYf 4iisO0+RsaPWCh/K6tg== X-Received: by 2002:a05:622a:2d6:b0:412:bea:af8f with SMTP id a22-20020a05622a02d600b004120beaaf8fmr795759qtx.23.1693427300232; Wed, 30 Aug 2023 13:28:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEr/zbDJqJwmga4rLUv71YzlWdaQHy+p+woDuUQ1UmqyzznpRA2FyueTuYN2uwZMFEkf9WwQQ== X-Received: by 2002:a05:622a:2d6:b0:412:bea:af8f with SMTP id a22-20020a05622a02d600b004120beaaf8fmr795750qtx.23.1693427299978; Wed, 30 Aug 2023 13:28:19 -0700 (PDT) Received: from [192.168.1.108] (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 d20-20020ac85354000000b00410ab3c78efsm3946091qto.11.2023.08.30.13.28.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 30 Aug 2023 13:28:19 -0700 (PDT) Message-ID: <053faf76-f918-7527-4a41-755a18d0018a@redhat.com> Date: Wed, 30 Aug 2023 16:28:18 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 From: Jason Merrill Subject: Re: [PATCH] c++: Check for indirect change of active union member in constexpr [PR101631] To: Nathaniel Shead , gcc-patches@gcc.gnu.org References: 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.2 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,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 8/29/23 09:35, Nathaniel Shead wrote: > This is an attempt to improve the constexpr machinery's handling of > union lifetime by catching more cases that cause UB. Is this approach > OK? > > I'd also like some feedback on a couple of pain points with this > implementation; in particular, is there a good way to detect if a type > has a non-deleted trivial constructor? I've used 'is_trivially_xible' in > this patch, but that also checks for a trivial destructor which by my > reading of [class.union.general]p5 is possibly incorrect. Checking for a > trivial default constructor doesn't seem too hard but I couldn't find a > good way of checking if that constructor is deleted. I guess the simplest would be (TYPE_HAS_TRIVIAL_DFLT (t) && locate_ctor (t)) because locate_ctor returns null for a deleted default ctor. It would be good to make this a separate predicate. > I'm also generally unsatisfied with the additional complexity with the > third 'refs' argument in 'cxx_eval_store_expression' being pushed and > popped; would it be better to replace this with a vector of some > specific structure type for the data that needs to be passed on? Perhaps, but what you have here is fine. Another possibility would be to just have a vec of the refs and extract the index from the ref later as needed. Jason