From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from cc-smtpout3.netcologne.de (cc-smtpout3.netcologne.de [89.1.8.213]) by sourceware.org (Postfix) with ESMTPS id CDCD2385624C; Fri, 16 Jun 2023 06:52:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CDCD2385624C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=netcologne.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=netcologne.de Received: from cc-smtpin3.netcologne.de (cc-smtpin3.netcologne.de [89.1.8.203]) by cc-smtpout3.netcologne.de (Postfix) with ESMTP id 3715A12307; Fri, 16 Jun 2023 08:52:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=netcologne.de; s=nc1116a; t=1686898349; bh=4d1k77C5jA+NpIT+nZohPD6bKpUvW4jY5r0FRHM29pU=; h=Message-ID:Date:Subject:To:Cc:References:From:In-Reply-To:From; b=n2HOrUbMz1ko2hA/70yfc6NKn92hQm52g9QDrc4n3a3oxx7XSCTPg4gecjiT2oQCU xdem1dCjUwbc9U9jV3JGR11yyz/VbRtbhRBmlRCcDj/QMkMHaMUunQefBCEWJYfRrf vfzBk7rUrQQMhmvbXTkqUppX5gpYNl6pMyUhOxHd0zcg6jS9eztwAPI2lvSkzA7V/8 dF/+uDxVA/EiDRCR4Qf/7NTlGypqRE58iwGZe+vG6Gu/2KSdRvOG9CKBkxnlDetz6V BaZnWAZskEL+W58o4LaGZzQXrLWkRBrQv9xuvajTCR/IOmTxUhOkVI77gROoKFpAnK fj9UoSP5UpMqQ== Received: from [IPV6:2001:4dd7:2d6e:0:7285:c2ff:fe6c:992d] (2001-4dd7-2d6e-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de [IPv6:2001:4dd7:2d6e:0:7285:c2ff:fe6c:992d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by cc-smtpin3.netcologne.de (Postfix) with ESMTPSA id B1DD611DE5; Fri, 16 Jun 2023 08:52:25 +0200 (CEST) Message-ID: <78806f60-27a0-1432-9bb2-1e2061414e67@netcologne.de> Date: Fri, 16 Jun 2023 08:52:24 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH] Introduce hardbool attribute for C To: Alexandre Oliva , Bernhard Reutner-Fischer , gcc-patches Cc: fortran@gcc.gnu.org References: <20230403012803.29ccf00b@nbbrfq> <6890D6BA-73DC-4F91-9413-228492A7F09B@gmail.com> Content-Language: en-US From: Thomas Koenig In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-NetCologne-Spam: L X-Rspamd-Action: no action X-Rspamd-Queue-Id: B1DD611DE5 X-Spamd-Bar: - X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: Hi Alexandre, > On Apr 6, 2023, Bernhard Reutner-Fischer wrote: > >> 29 For C_BOOL, the internal representation of .TRUE._C_BOOL and >> .FALSE._C_BOOL shall be the same as those of >> 30 the C values (_Bool)1 and (_Bool)0 respectively. > > I'm not changing any of the standard types, FWIW. The proposed > extension enables alternate boolean types to be introduced, with > extra checking for hardening. > >> I personally like your proposed 0 and ~0, that's probably pretty robust. > > That is only a default. Certain applications may benefit from other > values. 0xa5 and 0x5a seem to make a good combination too. In gfortran, we depend on the representation of 0/1 for several things (among them avoiding having separate library versions for logical kind=1,2,4,8,16 for MASK). So, such a type would be incompatible with vanilla LOGICAL variables and with C interop logical variables. If anybody should pass such a hardbool variable to Fortran, they will get unpredictable results, and deserve to lose. The opposite effect of what would be intended :-) Best regards Thomas