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.133.124]) by sourceware.org (Postfix) with ESMTPS id 229F53847718 for ; Wed, 3 Apr 2024 16:58:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 229F53847718 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 229F53847718 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712163498; cv=none; b=Ho3osYuNQkD3XcaykNF6/5jN9fSU9g9sLtZqJi4YufcwASEpfJ+11IPdHQAZTgkmjfRa5Ton7LlTS1FKuer0+qzDkU7mW3krMY1rCGGSLGxesQ/w2nMeS7L6YUEG5/pkEaF8xzz2mrDfawKzQ2OO0Z2sT5R5nI07TM7GSzBxMZk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712163498; c=relaxed/simple; bh=5nVEAGBIpIarplCGdxadfQqtl1GNVI+Yk5V3nNY8hXo=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=vvLvyngV17DjreyDNZWrTvGLPcjPTpX5oDoLmEzti8oMkJSvbVt70Wb0vtHWrGq+vK8gMIeEOYuTCr9fMcz2ersW+Nxg2/KBYvSTxordL07yvP8kO9gec0B0SGKw2N121kJVLyh/s6sNdmVdpUv8Q4opC9UiLrqZPhq1fz5iPOU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712163495; 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=4AG0+/FBkjgbI0eDQVvNgFZZ8WIN+MyI4q2+3RUIUug=; b=gQ7eFJsbRt82UG7Igf4mhc9toF9fssnjmOgBK/hpHL0u/06CC+YHOwE6ZpW3b5dmpLln0l rdzxTbMqfB3upBbpaBXSPItk7oLYqBVyxmkB88RQmu/Gn5+6l0waCovez8+2ChNeT5Loe4 IgM6vzDhyS08hOVXJA1GYgy4IYzMyBk= Received: from mail-yw1-f200.google.com (mail-yw1-f200.google.com [209.85.128.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-126-JJzU6XfrPoG8CKh9IIpRvQ-1; Wed, 03 Apr 2024 12:58:14 -0400 X-MC-Unique: JJzU6XfrPoG8CKh9IIpRvQ-1 Received: by mail-yw1-f200.google.com with SMTP id 00721157ae682-60cc8d4e1a4so934657b3.3 for ; Wed, 03 Apr 2024 09:58:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712163494; x=1712768294; 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=4AG0+/FBkjgbI0eDQVvNgFZZ8WIN+MyI4q2+3RUIUug=; b=LptOYPzAt55l0wCeFJ1qzbVvG+SbiIv14yRVvhtL2WoQWYSOS3IDAr4E6EZI5P3hia 3zw/d05vapB9Omh3amfZ1gUzvFOURA2MvQejbcqEEtVY4Q4zob9XzfQYFS0qx4u9O1lL dVgV/hO8zER6hwRzLBPn+trwYhL6xxVaTQw3Q8ZisJjP4yebZqbTk4cgGosEX3tevTXB q5IysLGHdep+Dj+yWT0RHn7m98fT0Y1/5obIOCG85lFvsRpLGqL34bN0+TH0+tJQSHdA vT3fSEMnHjso+93Fm63yoCH74nyPq6iRMVch20ab/kua5HcXuH+5AZSzlo65iAVBfCoy ZLUw== X-Gm-Message-State: AOJu0YzZ3f0ut23cW3I6VhRhYE+2bpKwmlVEDAM6PHxEPesZvwon52Ji VMcJZSC6YvdQqUi4YdJbQjeY+t9Py1v7e5WvKozhOY8zVhocJ90zAHujSQXnvdxoVYgcfMtNyki mb/DlDUvKvv8QMZ2m9sPwMQZ0kRfI1aamtsXBwT87H9LcVe955JPmcsE= X-Received: by 2002:a81:a747:0:b0:614:8185:2946 with SMTP id e68-20020a81a747000000b0061481852946mr12278228ywh.42.1712163493873; Wed, 03 Apr 2024 09:58:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGhJhagwxa4UrI9OoAIqyXx214399Iske8W778zfo+fS6z7W8M0vZgsysUwQyd0fO5FlT4W+A== X-Received: by 2002:a81:a747:0:b0:614:8185:2946 with SMTP id e68-20020a81a747000000b0061481852946mr12278200ywh.42.1712163493503; Wed, 03 Apr 2024 09:58:13 -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 ep16-20020a05622a549000b004313b7cf2c7sm6758149qtb.39.2024.04.03.09.58.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 03 Apr 2024 09:58:13 -0700 (PDT) Message-ID: Date: Wed, 3 Apr 2024 12:58:12 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] c++: Implement C++26 P2809R3 - Trivial infinite loops are not Undefined Behavior To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org References: <8166752c-6ad7-4b56-a451-da614234e47f@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=-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/3/24 12:42, Jakub Jelinek wrote: > On Wed, Apr 03, 2024 at 12:07:48PM -0400, Jason Merrill wrote: >> Using std::is_constant_evaluated directly in a loop condition is, as the >> paper says, unlikely and "horrendous code", so I'm not concerned about >> surprising effects, though I guess we should check for it with >> maybe_warn_for_constant_evaluated. > > Ok, though guess the question is what to say about it. > Because unlike the existing cases in maybe_warn_for_constant_evaluated > where it always evaluates to true or always to false depending on where, > in the trivial empty iteration statements it evaluates to always true or > always false depending or sometimes true, sometimes false, depending on > if the condition is a constant expression that evaluates to true (then it is > always true), or if in immediate function (also always true), or if not > in constexpr function (then always false), or in constexpr function (then > it might be true or false). > Not sure how exactly to word that. > Maybe just say that it is horrendous code to use std::is_constant_evaluated > () in trivial empty iteration statement conditions ;) Maybe if the condition constant-evaluates to true, warn something like "% always constant-evaluates to true in the condition of a trivially empty iteration statement"? > What about loops with non-empty bodies or other reasons why they aren't > trivial empty iteration statements? Shall we do > maybe_warn_for_constant_evaluated for those (with the current wording, > false in non-constexpr fn, true in consteval)? Sounds good. Jason