From owner-freebsd-hackers@freebsd.org Fri Jan 15 18:11:58 2021 Return-Path: Delivered-To: freebsd-hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3F04B4EDB5C for ; Fri, 15 Jan 2021 18:11:58 +0000 (UTC) (envelope-from "") Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4DHTlx2vK7z3Lc8 for ; Fri, 15 Jan 2021 18:11:57 +0000 (UTC) (envelope-from "") Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 7E7A0160062 for ; Fri, 15 Jan 2021 19:11:54 +0100 (CET) Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4DHTlr47Ltz9rxS; Fri, 15 Jan 2021 19:11:52 +0100 (CET) From: Walter von Entferndt To: Mark Millard Cc: freebsd-hackers@freebsd.org Subject: Re: Implicit assumptions (was: Re: Some fun with -O2) Date: Fri, 15 Jan 2021 19:11:47 +0100 Message-ID: <2310709.D6tDg3Ca2R@t450s.local.lan> In-Reply-To: <8D35ADAE-8904-4400-9DEB-7B274189BC30@yahoo.com> References: <4842729.YNO7O01DYZ@t450s.local.lan> <8D35ADAE-8904-4400-9DEB-7B274189BC30@yahoo.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Rspamd-Queue-Id: 4DHTlx2vK7z3Lc8 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=posteo.net (policy=none); spf=none (mx1.freebsd.org: domain of mout01.posteo.de has no SPF policy when checking 185.67.36.141) smtp.helo=mout01.posteo.de X-Spamd-Result: default: False [-2.70 / 15.00]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_MED(-0.20)[185.67.36.141:from]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_HAM_SHORT(-1.00)[-1.000]; R_SPF_NA(0.00)[no SPF record]; FREEMAIL_TO(0.00)[yahoo.com]; R_DKIM_NA(0.00)[]; CTE_CASE(0.50)[]; ASN(0.00)[asn:8495, ipnet:185.67.36.0/23, country:DE]; MIME_TRACE(0.00)[0:+]; MAILMAN_DEST(0.00)[freebsd-hackers]; DMARC_POLICY_SOFTFAIL(0.10)[posteo.net : No valid SPF, No valid DKIM,none] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jan 2021 18:11:58 -0000 At Freitag, 15. Januar 2021, 08:02:49 CET Mark Millard wrote: > FYI: C itself has, in , CHAR_BIT for the number of bits in a > Byte for how sizeof counts Bytes: sizeof(char), sizeof(signed char), > and sizeof(unsigned char) are each always 1. > No, CHAR_BIT is the #bits in a *char*, which is the (standard) datatype for the binary representation of a character/letter/symbol in written human language, and for small integers. The name also suggests that, as well as the comment in the header file. That does not necessarily equal a "byte", which (by commonly accepted knowledge) is the smallest addressable entity in a computer's memory. Of course, e.g. https://code-reference.com/c/datatypes/ char tells a *char* occupies one byte. Sadly, AFAIK C itself does not define what a "byte" is, although that term is mentioned many times in reference manuals (implicit assumption). So /theoretically/ CHAR_BIT and NBBY can differ. In fact, many library funtions operating on characters/letters take an *int* instead of a *char* for performance reasons. From https://code-reference.com/c/stdlib.h/sizeof: "the *sizeof* operator returns the number of bytes to be reserved for a variable or a data type". Of course, for practical reasons, we can safely assume that a *char* will take one byte in storage space for the foreseeable future, since the consequences of changing that would be disastrous. -- =|o) "Stell' Dir vor es geht und keiner kriegt's hin." (Wolfgang Neuss)