From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 16344 invoked from network); 20 Apr 2022 10:20:28 -0000 Received: from tb-ob21.topicbox.com (173.228.157.67) by inbox.vuxu.org with ESMTPUTF8; 20 Apr 2022 10:20:28 -0000 Received: from tb-mx0.topicbox.com (tb-mx0.nyi.icgroup.com [10.90.30.73]) by tb-ob21.topicbox.com (Postfix) with ESMTP id 9C1561A614 for ; Wed, 20 Apr 2022 06:20:24 -0400 (EDT) (envelope-from bounce.mMb38696f1b928920ec2c4d16d.r522be890-2105-11eb-b15e-8d699134e1fa@9fans.bounce.topicbox.com) Received: by tb-mx0.topicbox.com (Postfix, from userid 1132) id 399584AEA408; Wed, 20 Apr 2022 06:20:24 -0400 (EDT) ARC-Authentication-Results: i=2; topicbox.com; arc=pass; dkim=none (no signatures found); dmarc=pass policy.published-domain-policy=none policy.published-subdomain-policy=none policy.applied-disposition=none policy.evaluated-disposition=none (p=none,sp=none,d=none,d.eval=none) policy.policy-from=p header.from=sdf.org; spf=pass smtp.mailfrom=adr@SDF.ORG smtp.helo=mx.sdf.org; x-internal-arc=fail (as.1.topicbox.com=pass, ams.1.topicbox.com=fail (message has been altered)) (Message modified while forwarding at Topicbox) ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d= topicbox.com; h=date:from:to:message-id:mime-version :content-type:list-help:list-id:list-post:list-subscribe :reply-to:subject:content-transfer-encoding:list-unsubscribe; s= sysmsg-1; t=1650450024; bh=qY9PGfyeUJq6hxgKniC5zIcKtE1deTusL3Rc+ n1I+xQ=; b=UTj2lFWEVkk1yDw2/U/Hn0Yf00Mp/yEIM6yFWMaW+eHw3VUMgwiIl B9ChJGFooel1l1XGd8ODewjBCU5aQ2fs0qPqVzbzODMaj53x68zX/RwN2ABJU0P9 Yv7VTZ9s3e32s/IbiyIBWk6WId8mcLGoJjEHovJN3ibWWDavS9X8Lc= ARC-Seal: i=2; a=rsa-sha256; cv=pass; d=topicbox.com; s=sysmsg-1; t= 1650450024; b=ZtLc2zNR5hs+3rckoPptAeHus6CPlwd5p0BE8hf5eqdqGnhomJ UUb8y/rqaYWIl1j5ItgVkCoozXk8nKkwzi+kAx2uw73K8xY/Ql1Eo4QRxy+RIVBc qQBEBpv1ctKERbSMfT5Fdi7Lojz2N/jmQ+N781HoKYB0W0VhBxb+wMzA8= Authentication-Results: topicbox.com; arc=pass; dkim=none (no signatures found); dmarc=pass policy.published-domain-policy=none policy.published-subdomain-policy=none policy.applied-disposition=none policy.evaluated-disposition=none (p=none,sp=none,d=none,d.eval=none) policy.policy-from=p header.from=sdf.org; spf=pass smtp.mailfrom=adr@SDF.ORG smtp.helo=mx.sdf.org; x-internal-arc=fail (as.1.topicbox.com=pass, ams.1.topicbox.com=fail (message has been altered)) (Message modified while forwarding at Topicbox) X-Received-Authentication-Results: tb-mx1.topicbox.com; arc=none (no signatures found); bimi=skipped (DMARC Policy is not at enforcement); dkim=none (no signatures found); dmarc=pass policy.published-domain-policy=none policy.published-subdomain-policy=none policy.applied-disposition=none policy.evaluated-disposition=none (p=none,sp=none,d=none,d.eval=none) policy.policy-from=p header.from=sdf.org; iprev=pass smtp.remote-ip=205.166.94.24 (mx.sdf.org); spf=pass smtp.mailfrom=adr@SDF.ORG smtp.helo=mx.sdf.org; x-aligned-from=pass (Address match); x-me-sender=none; x-ptr=pass smtp.helo=mx.sdf.org policy.ptr=mx.sdf.org; x-return-mx=pass header.domain=sdf.org policy.is_org=yes (MX Records found: mx.sdf.org); x-return-mx=pass smtp.domain=sdf.org policy.is_org=yes (MX Records found: mx.sdf.org); x-tls=pass smtp.version=TLSv1.2 smtp.cipher=ECDHE-RSA-AES256-GCM-SHA384 smtp.bits=256/256; x-vs=clean score=0 state=0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=9fans.net; h=date:from :to:message-id:mime-version:content-type:list-help:list-id :list-post:list-subscribe:reply-to:subject :content-transfer-encoding:list-unsubscribe; s=dkim-1; bh=nn0URx s7Cfw3i1WkQbLRuUwQQWyc6FeXdajqIQMuJxM=; b=qPkL3VrnSl6Eeoqf73v+IH DiMsxZuUk+O55bIYijZ8XrxxovgahoFOk0oEvx1hkzVErLnTAEW+OFXmG5Mtefal jCBinx/FMRBIrj023NaZzgfiqsG7vpidaiv1afqwkrkIXsONXXY6Q0fH4DUZEZWj 1FgR0M92uMhEAnKvaZhgw= Received: from tb-mx1.topicbox.com (localhost.local [127.0.0.1]) by tb-mx1.topicbox.com (Postfix) with ESMTP id 986E5139E4CA for <9fans@9fans.net>; Wed, 20 Apr 2022 06:20:04 -0400 (EDT) (envelope-from adr@SDF.ORG) Received: from tb-mx1.topicbox.com (localhost [127.0.0.1]) by tb-mx1.topicbox.com (Authentication Milter) with ESMTP id AE39A965B41; Wed, 20 Apr 2022 06:20:04 -0400 ARC-Seal: i=1; a=rsa-sha256; cv=none; d=topicbox.com; s=arcseal; t= 1650450004; b=l8Ge9NR24deyKe5UGKQTfsujQ/JpctNnsn87qoowF3xe/QojQv EsGhK+9xW+Bv7dmEWhLDrNiy+TVmV7rHgczr/crzgH7CIWmm6JpvW8T4BsbwSz+V b2mkMs+bBcLaF7svOlrfoXbSPvmQ1H3Ih+SpEBIMZxiub8aySqyYsKERJoh+re/M MicbMnAmdbzwsO+9r3HKytduREtAUVVClXS22NdH1LrLa+pNVxTJxRph5bJokqvZ s5+bSFTt9pvboF0PFXuVG27ckjXr3IvGTC4cCzlXkI0ewpSXVykJeeklYzYqLVbK CR8PM47wGZsRmcJ63jt6byQSpUQXJAOm3fcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= topicbox.com; h=date:from:to:subject:message-id:mime-version :content-type; s=arcseal; t=1650450004; bh=SZw65zKnB821KRjkIHHbi Zq9fyoDCTEz8vMhdqc8Yw4=; b=m1IG5DGzARz+/NZRZE6Sdq4aWA1rA5YQ/3Vk5 PX2Wn4mYalFmJ0S8ekUm1JKnalRjhDhcKYSMzzS1eJQp4hRX/r8aT/3OBbMPTSiT sTQC0zFezL8W1EVHgCAcOrdv+9Mv0A5if1LhkrNklTr3k6c48Cr7rKTc9nC/1ZV8 W8ap87CpQD9Ufh6ihDPlymzRMx3XHZ1w2N5xIYX+r10dgZ6ryK+wlj1gkRQqvOTw eP9e29SpdzuGzXhhf3RxgaHEVLX2RtG3aeHO6PRxWxSIdiJmiPmTTuwErKtFGACI cclXCWxKWsyCVAiij0kSf635lXxMoQC68v63Q3xV8oXFd1tuw== ARC-Authentication-Results: i=1; tb-mx1.topicbox.com; arc=none (no signatures found); bimi=skipped (DMARC Policy is not at enforcement); dkim=none (no signatures found); dmarc=pass policy.published-domain-policy=none policy.published-subdomain-policy=none policy.applied-disposition=none policy.evaluated-disposition=none (p=none,sp=none,d=none,d.eval=none) policy.policy-from=p header.from=sdf.org; iprev=pass smtp.remote-ip=205.166.94.24 (mx.sdf.org); spf=pass smtp.mailfrom=adr@SDF.ORG smtp.helo=mx.sdf.org; x-aligned-from=pass (Address match); x-me-sender=none; x-ptr=pass smtp.helo=mx.sdf.org policy.ptr=mx.sdf.org; x-return-mx=pass header.domain=sdf.org policy.is_org=yes (MX Records found: mx.sdf.org); x-return-mx=pass smtp.domain=sdf.org policy.is_org=yes (MX Records found: mx.sdf.org); x-tls=pass smtp.version=TLSv1.2 smtp.cipher=ECDHE-RSA-AES256-GCM-SHA384 smtp.bits=256/256; x-vs=clean score=0 state=0 X-ME-VSCause: gggruggvucftvghtrhhoucdtuddrgedvfedrtddtgddtudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukf ggtgesthdtredttddtvdenucfhrhhomheprggurhcuoegrughrsefufffhrdfqtffiqeen ucggtffrrghtthgvrhhnpeekvdekheevfffhgeeviefhkeduleelhfekudffleeuhfdvje fhkeekjedvteduudenucffohhmrghinhepfhhrvggvshhhvghllhdrohhrghenucfkphep vddthedrudeiiedrleegrddvgedpvddthedrudeiiedrleegrdduieenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvtdehrdduieeirdelgedrvdegpdhh vghlohepmhigrdhsughfrdhorhhgpdhmrghilhhfrhhomhepoegrughrsefufffhrdfqtf fiqe X-ME-VSScore: 0 X-ME-VSCategory: clean Received-SPF: pass (sdf.org: 205.166.94.24 is authorized to use 'adr@SDF.ORG' in 'mfrom' identity (mechanism 'ip4:205.166.94.0/24' matched)) receiver=tb-mx1.topicbox.com; identity=mailfrom; envelope-from="adr@SDF.ORG"; helo=mx.sdf.org; client-ip=205.166.94.24 Received: from mx.sdf.org (mx.sdf.org [205.166.94.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by tb-mx1.topicbox.com (Postfix) with ESMTPS for <9fans@9fans.net>; Wed, 20 Apr 2022 06:20:02 -0400 (EDT) (envelope-from adr@SDF.ORG) Received: from sdf.org (IDENT:adr@sdf.org [205.166.94.16]) by mx.sdf.org (8.15.2/8.14.5) with ESMTPS id 23KAJxah009297 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO) for <9fans@9fans.net>; Wed, 20 Apr 2022 10:20:00 GMT Received: from localhost (adr@localhost) by sdf.org (8.15.2/8.12.8/Submit) with ESMTP id 23KAJwBm017409 for <9fans@9fans.net>; Wed, 20 Apr 2022 10:19:59 GMT Date: Wed, 20 Apr 2022 10:19:58 +0000 (UTC) From: adr To: 9fans@9fans.net Message-ID: <16a447c9-e11-c379-598-7430d2ed39d4@SDF.ORG> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Topicbox-Policy-Reasoning: allow: sender is a member Topicbox-Message-UUID: 7673d652-c093-11ec-81aa-f74d0e733ac9 Archived-At: =?UTF-8?B?PGh0dHBzOi8vOWZhbnMudG9waWNib3guY29tL2dyb3Vwcy85?= =?UTF-8?B?ZmFucy9UMjI3NTRmMTBiMjQxOTkxYy1NYjM4Njk2ZjFiOTI4OTIwZWMyYzRk?= =?UTF-8?B?MTZkPg==?= List-Help: List-Id: "9fans" <9fans.9fans.net> List-Post: List-Software: Topicbox v0 List-Subscribe: Precedence: list Reply-To: 9fans <9fans@9fans.net> Subject: [9fans] Conversion of constants in C compiler Content-Transfer-Encoding: quoted-printable List-Unsubscribe: , Topicbox-Delivery-ID: 2:9fans:437d30aa-c441-11e9-8a57-d036212d11b0:522be890-2105-11eb-b15e-8d699134e1fa:Mb38696f1b928920ec2c4d16d:1:_SX3tjIbHKbOvg1NFzMOj5x2zGjwfa2VFfVtZ3VBysE Hi. I've been tinkering again with the dist I shared before in http://adr.freeshell.org/plan9, basically 9legacy + Miller's 9pi + 9front's libseq. Importing ori's git9 I noticed that the compiler was truncating a constant without the correspondent suffix. According to C99, the type of a constant should be the first in which its value can be represented following this table: Suffix Decimal 0 or 0x ---------------------------------------------------------- none int int long int unsigned int long long int long int unsigned long int unsigned long long int ---------------------------------------------------------- u|U unsigned int unsigned int unsigned long int unsigned long int unsigned long long int unsigned long long int ---------------------------------------------------------- l|L long int long int long long int unsigned long int long long int unsigned long long int ---------------------------------------------------------- u|U & l|L unsigned long int unsigned long int unsigned long long int unsigned long long int ---------------------------------------------------------- ll|LL long long int long long int unsigned long long int ---------------------------------------------------------- u|U & ll|LL unsigned long long int ---------------------------------------------------------- Which follows the K&R description at "A.2.5.1 Integer Constants", just addi= ng LL. Now, in plan9 constants are of type int if there is no suffix, or of the one specified by the suffix. The only change made is from a signed type to an unsigned one if it is necessary to fit the constant's value. The rest is truncated: /sys/src/cmd/cc/lex.c: [...] vv =3D yylval.vval; if(c1 & Numvlong) { if((c1 & Numuns) || convvtox(vv, TVLONG) < 0) { c =3D LUVLCONST; t =3D TUVLONG; goto nret; } c =3D LVLCONST; t =3D TVLONG; goto nret; } if(c1 & Numlong) { if((c1 & Numuns) || convvtox(vv, TLONG) < 0) { c =3D LULCONST; t =3D TULONG; goto nret; } c =3D LLCONST; t =3D TLONG; goto nret; } if((c1 & Numuns) || convvtox(vv, TINT) < 0) { c =3D LUCONST; t =3D TUINT; goto nret; } c =3D LCONST; t =3D TINT; goto nret; nret: yylval.vval =3D convvtox(vv, t); if(yylval.vval !=3D vv){ nearln =3D lineno; warn(Z, "truncated constant: %T %s", types[t], symb); } return c; [...] 9front introduces some widening: [...] vv =3D yylval.vval; /* * c99 is silly: decimal constants stay signed, * hex and octal go unsigned before widening. */ w =3D 32; if((c1 & (Numdec|Numuns)) =3D=3D Numdec) w =3D 31; if(c1 & Numvlong || (c1 & Numlong) =3D=3D 0 && (uvlong)vv >=3D 1ULL= <