From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DB7C20F1 for ; Tue, 23 Jan 2024 20:36:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706042163; cv=none; b=F1W4TQbBuQGpSxiEn8oKNGMUO8st2yaRG6kgShZbs9lGD0zfS+1HhEApB4VQe5ZguyHWgrvD+Ur/C6Y33MZ2GAjoYhceKIrTZnd4a597eR26Awkab9IBgHZKTSd+Lvqlz/w65ZRJGAcVy0gjyfP0Ow3+ZBLn3PHkNKjUJoE8yUM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706042163; c=relaxed/simple; bh=Vm5D2XrTyYxnG2wg70kikdOtB2QnvPMkSG4ncD/DbZQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: In-Reply-To:Content-Type:Content-Disposition; b=u6wQz9GzufoujritVNjK74cH1ZZ92sO2BbFEtcISOklZ24I45LkEZZW/Zid9F6fIXBBwWWYKcalhHHQAR5ZjnwtBkV07s5MeorDODUUr4XOEsffkbT9SuG1ihPe9hnoyp3xQ5FUZLyFZSOUuHa4akjJTdG/AddQiukmqKeER8LA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ftOYM2br; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ftOYM2br" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706042160; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=bLQqOOn4N8U6JdCxUfvEi4Xlyh3At/9FJ/EnwilRYcs=; b=ftOYM2brmVGD0ySqLL4W4AfxqmVWPUlf5odfhq4QNqi3K1R3+djnbd/eyzLQUDWy64NUJf anEZr1m5CFo2MyfSUiS/qtQZAiof/rMve9+bp4t++4t7q3ABg0nJ0CMmmCgvCw/d5nzqRW PrdlVLziYJs+NsuXYYPzXCh3RdWbkmg= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-637-vkkHOq_yPNWCBUF9PhlMQA-1; Tue, 23 Jan 2024 15:35:53 -0500 X-MC-Unique: vkkHOq_yPNWCBUF9PhlMQA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 781782812FEA; Tue, 23 Jan 2024 20:35:52 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 22D392026D66; Tue, 23 Jan 2024 20:35:52 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 40NKZmNl1684042 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 23 Jan 2024 21:35:48 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 40NKZkTL1684041; Tue, 23 Jan 2024 21:35:46 +0100 Date: Tue, 23 Jan 2024 21:35:46 +0100 From: Jakub Jelinek To: Linus Torvalds Cc: paulmck@kernel.org, linux-toolchains@vger.kernel.org, peterz@infradead.org, hpa@zytor.com, rostedt@goodmis.org, gregkh@linuxfoundation.org, keescook@chromium.org Subject: Re: A few proposals from the C standards committee Message-ID: Reply-To: Jakub Jelinek References: <9162660e-2d6b-47a3-bfa2-77bfc55c817b@paulmck-laptop> <70fd47bb-1539-4301-9cd0-1b94aa066205@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-toolchains@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Jan 23, 2024 at 12:20:14PM -0800, Linus Torvalds wrote: > And no, __builtin_unreachable() is not it either, because it again has > the same issue as "assert()" - in *practice* compilers can use it as a > hint, but that's an incidental result, not part of a documented "this > is how you specify a known range" > > So yes, I can do things like > > if (a < 0) __builtin_unreachable(); > > and it will generate the *code* that I want, but it sure as hell isn't > some standard C syntax. C++23 has [[assume (condition)]]; for this (see https://wg21.link/p1774r8) and GCC supports it also as [[gnu::assume (condition)]] and __attribute__((assume (condition)));, both in C (the former only in C23) and C++. Side-effects in condition aren't evaluated, so it has different behavior from if (!(condition)) __builtin_unreachable (); Jakub