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 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 31769 invoked from network); 28 Apr 2022 02:44:20 -0000 Received: from tb-ob0.topicbox.com (64.147.108.117) by inbox.vuxu.org with ESMTPUTF8; 28 Apr 2022 02:44:20 -0000 Received: from tb-mx0.topicbox.com (tb-mx0.nyi.icgroup.com [10.90.30.73]) by tb-ob0.topicbox.com (Postfix) with ESMTP id 771E035AE8 for ; Wed, 27 Apr 2022 22:44:15 -0400 (EDT) (envelope-from bounce.mM4a92d1c5d54d32d3f8221d1e.r522be890-2105-11eb-b15e-8d699134e1fa@9fans.bounce.topicbox.com) Received: by tb-mx0.topicbox.com (Postfix, from userid 1132) id 75ABE4BA3646; Wed, 27 Apr 2022 22:44:15 -0400 (EDT) ARC-Authentication-Results: i=2; topicbox.com; arc=pass; dkim=none (no signatures found); dmarc=pass policy.published-domain-policy=none policy.applied-disposition=none policy.evaluated-disposition=none (p=none,d=none,d.eval=none) policy.policy-from=p header.from=eigenstate.org; spf=pass smtp.mailfrom=ori@eigenstate.org smtp.helo=mimir.eigenstate.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=message-id:to:subject:date:from:in-reply-to :mime-version:content-type:content-transfer-encoding:list-help :list-id:list-post:list-subscribe:reply-to:list-unsubscribe; s= sysmsg-1; t=1651113855; bh=bWZbpEnxMFpQi+pGJq/fojUQcHTmfhbGbc5c4 IO/k2c=; b=FTqzgTB8RhpLfiPTQNBIGDK+SxlN0x+ktk+gF7IIgT+BvaBulce5v x/mMaFti84JRShB3a0NMEpmI5g9l5zwFR2KNC93GK1Ho6I77+qWOs3w5VAl87iKw AgxNujHKk1ivkFcARTxGzrPCk0gvOxeL5FEehk7S4U6zQjH7TyHCRA= ARC-Seal: i=2; a=rsa-sha256; cv=pass; d=topicbox.com; s=sysmsg-1; t= 1651113855; b=ZQFKWq2xWsKvNudcYYKfXm7svI4Apab19VG4dx95kqiRAEjF0U lO0oTk5AdB/xJPlUCB6wrdsShUOJaMjFuvLQ5Op6UU5RVinuf79mryWJNZJav4Xg 1zK6triVaOLwQx27KIzpu/dBDRiTK+/WFEubCQMJbSD57NrHLlyP1Q/Jc= Authentication-Results: topicbox.com; arc=pass; dkim=none (no signatures found); dmarc=pass policy.published-domain-policy=none policy.applied-disposition=none policy.evaluated-disposition=none (p=none,d=none,d.eval=none) policy.policy-from=p header.from=eigenstate.org; spf=pass smtp.mailfrom=ori@eigenstate.org smtp.helo=mimir.eigenstate.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-mx0.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.applied-disposition=none policy.evaluated-disposition=none (p=none,d=none,d.eval=none) policy.policy-from=p header.from=eigenstate.org; iprev=pass smtp.remote-ip=206.124.132.107 (mimir.eigenstate.org); spf=pass smtp.mailfrom=ori@eigenstate.org smtp.helo=mimir.eigenstate.org; x-aligned-from=pass (Address match); x-me-sender=none; x-ptr=pass smtp.helo=mimir.eigenstate.org policy.ptr=mimir.eigenstate.org; x-return-mx=pass header.domain=eigenstate.org policy.is_org=yes (MX Records found: eigenstate.org,nokogiri.pikopiko.org,kusuri.pikopiko.org,mail.pikopiko.org); x-return-mx=pass smtp.domain=eigenstate.org policy.is_org=yes (MX Records found: eigenstate.org,nokogiri.pikopiko.org,kusuri.pikopiko.org,mail.pikopiko.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=message-id :to:subject:date:from:in-reply-to:mime-version:content-type :content-transfer-encoding:list-help:list-id:list-post :list-subscribe:reply-to:list-unsubscribe; s=dkim-1; bh=zuTst0Et NQA0faXh6SsjO3WHSdcBPo2mufZNrD3sSKw=; b=R3DhH4y5gNGrPeHBvz6XBNLK Rd5EkqB2iYweaV4K2R6wO+PdxB4EqSoxEh0yO40oZILzr1ce6Y3nH3JAZtHm+P3t 4+PX8mqalKm5vg0rTvThBnKiUuutzNCXcOKWuHOLTPXndIUCH0t+tN21njsYJWVX Aqpy5cH0sDlw99WciDc= Received: from tb-mx0.topicbox.com (localhost.local [127.0.0.1]) by tb-mx0.topicbox.com (Postfix) with ESMTP id 2C5AA4BA322D for <9fans@9fans.net>; Wed, 27 Apr 2022 22:44:03 -0400 (EDT) (envelope-from ori@eigenstate.org) Received: from tb-mx0.topicbox.com (localhost [127.0.0.1]) by tb-mx0.topicbox.com (Authentication Milter) with ESMTP id F34D19BB553; Wed, 27 Apr 2022 22:44:03 -0400 ARC-Seal: i=1; a=rsa-sha256; cv=none; d=topicbox.com; s=arcseal; t= 1651113843; b=P/NWvwuorALL8eT/nUv3iRt0OWxeMyZ/DfzJQ3Log8B0Tv7eIW i3ThwZjJ/iVQ/P21HOzoVdFIWBA/2IxrB1aZ0XIdtm2p848bqdb0ZZKG1SBZsJmd DpMcmepzeIE6yUHJkClNaT8yH9hiNwxCcgOcQwkxeoFX9kOXrJcw3iNthnCiwp01 lqCWDt3RaM2rvXYZlcoy8TgLWPmZ3/8wwCxm9OTYaW2dwnUqRKvvnORSb0Zmm7eq CgUmXStAD6PyZ/ULVPn5/BtlpizhNkkB6GlunIHaKPZWx9TwY3FacxcD7TrwDKcH 3A6qZpm2hBtBeE/88ryunoAABZmdkbMJFPDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= topicbox.com; h=message-id:to:subject:date:from:in-reply-to :mime-version:content-type:content-transfer-encoding; s=arcseal; t=1651113843; bh=ETXfirgZXzXANi5JcVCgyVnujRO2w25oNJuuoe1U+QE=; b= b5QDv7AjuD3aXwcQiqWC+enrCcBvS11bzEWL0NBwFhKORY6h6LqpOYn6tGv502E/ L44b9X9kHhp2USHVcVy5jItB35mu29CuKEhelLOTu4WVlBCxRDL+Gabx4P+5y7sx 087O8zvnbDGiK1dawgOZDSYuqDhnVwYmsvGd0hNGu2sqJVAgiAWIZZYOhpdqHgdk CCGOXCziZ2oUqpoH7IwXHrlPuoOBrOG6N8ZKpGea1Q0isSPJ12tUmywHH0O0gvpo /HUvziuUP89YoVOie0vRLIvr5VZp0JaJaWEwe2HIgYELu3YGM8WUZNgml3DtaRPd Kg+5I0Cx+LCCs9/belpuqA== ARC-Authentication-Results: i=1; tb-mx0.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.applied-disposition=none policy.evaluated-disposition=none (p=none,d=none,d.eval=none) policy.policy-from=p header.from=eigenstate.org; iprev=pass smtp.remote-ip=206.124.132.107 (mimir.eigenstate.org); spf=pass smtp.mailfrom=ori@eigenstate.org smtp.helo=mimir.eigenstate.org; x-aligned-from=pass (Address match); x-me-sender=none; x-ptr=pass smtp.helo=mimir.eigenstate.org policy.ptr=mimir.eigenstate.org; x-return-mx=pass header.domain=eigenstate.org policy.is_org=yes (MX Records found: eigenstate.org,nokogiri.pikopiko.org,kusuri.pikopiko.org,mail.pikopiko.org); x-return-mx=pass smtp.domain=eigenstate.org policy.is_org=yes (MX Records found: eigenstate.org,nokogiri.pikopiko.org,kusuri.pikopiko.org,mail.pikopiko.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: gggruggvucftvghtrhhoucdtuddrgedvfedrudeigdeigecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhepkffvufffhf gjgggtgfesthejjedttddtvdenucfhrhhomhepohhrihesvghighgvnhhsthgrthgvrdho rhhgnecuggftrfgrthhtvghrnhephfethefgjeejudelheefudevudegheekjeejheetfe eifedugeelkeetteegvdeknecuffhomhgrihhnpehonhhlhielfhgrnhhsrdgtohhmnecu kfhppedvtdeirdduvdegrddufedvrddutdejpdejgedruddtkedrheeirddvvdehnecuve hluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvddtiedruddvgedrudef vddruddtjedphhgvlhhopehmihhmihhrrdgvihhgvghnshhtrghtvgdrohhrghdpmhgrih hlfhhrohhmpeeoohhrihesvghighgvnhhsthgrthgvrdhorhhgqe X-ME-VSScore: 0 X-ME-VSCategory: clean Received-SPF: pass (eigenstate.org: 206.124.132.107 is authorized to use 'ori@eigenstate.org' in 'mfrom' identity (mechanism 'mx' matched)) receiver=tb-mx0.topicbox.com; identity=mailfrom; envelope-from="ori@eigenstate.org"; helo=mimir.eigenstate.org; client-ip=206.124.132.107 Received: from mimir.eigenstate.org (mimir.eigenstate.org [206.124.132.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by tb-mx0.topicbox.com (Postfix) with ESMTPS for <9fans@9fans.net>; Wed, 27 Apr 2022 22:44:02 -0400 (EDT) (envelope-from ori@eigenstate.org) Received: from abbatoir.myfiosgateway.com (pool-74-108-56-225.nycmny.fios.verizon.net [74.108.56.225]) by mimir.eigenstate.org (OpenSMTPD) with ESMTPSA id 30795c11 (TLSv1.2:ECDHE-RSA-AES256-SHA:256:NO) for <9fans@9fans.net>; Wed, 27 Apr 2022 19:44:01 -0700 (PDT) Message-ID: <3C132FBD69F1EB1594B8F56989784069@eigenstate.org> To: 9fans@9fans.net Subject: Re: [9fans] Conversion of constants in C compiler Date: Wed, 27 Apr 2022 22:43:59 -0400 From: ori@eigenstate.org In-Reply-To: <8530f0d7-7c38-92af-d649-23f99645b748@SDF.ORG> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Topicbox-Policy-Reasoning: allow: sender is a member Topicbox-Message-UUID: 13ceeefa-c69d-11ec-b9ed-b7173d547f53 Archived-At: =?UTF-8?B?PGh0dHBzOi8vOWZhbnMudG9waWNib3guY29tL2dyb3Vwcy85?= =?UTF-8?B?ZmFucy9UMjI3NTRmMTBiMjQxOTkxYy1NNGE5MmQxYzVkNTRkMzJkM2Y4MjIx?= =?UTF-8?B?ZDFlPg==?= List-Help: List-Id: "9fans" <9fans.9fans.net> List-Post: List-Software: Topicbox v0 List-Subscribe: Precedence: list Reply-To: 9fans <9fans@9fans.net> List-Unsubscribe: , Topicbox-Delivery-ID: 2:9fans:437d30aa-c441-11e9-8a57-d036212d11b0:522be890-2105-11eb-b15e-8d699134e1fa:M4a92d1c5d54d32d3f8221d1e:1:eha00TQp7yNT9n7zzTbrVB7sjVPJ-McW-wufCpIfNvU Quoth adr : > On Wed, 20 Apr 2022, ori@eigenstate.org wrote: > > When you have a patch, let me know -- I'll happily test > > and apply to 9front. >=20 > Hi ori, this patch applyes to the sources served at 9front.org. > By the way, do you plan to keep in sync > http://only9fans.com/ori/git9/HEAD/info.html or should I forget > about that repo? >=20 > Regards, > adr. >=20 > --- /n/9front/sys/src/cmd/cc/lex.c Wed Apr 6 14:45:26 2022 > +++ /tmp/lex.c Thu Apr 21 08:39:14 2022 > @@ -848,16 +848,9 @@ > yyerror("overflow in constant"); >=20 > 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 1U= LL< - if((c1&(Numdec|Numvlong)) =3D=3D Numdec && vv < 1ULL<<32) > - warn(Z, "int constant widened to vlong: %s", symb= ); > + if(c1 & Numvlong || > + convvtox(vv, TUVLONG) > convvtox(vv, TULONG) || > + (c1 & (Numdec|Numuns)) =3D=3D Numdec && convvtox(vv, TLONG) < 0= ) { > if((c1 & Numuns) || convvtox(vv, TVLONG) < 0) { > c =3D LUVLCONST; > t =3D TUVLONG; Thanks for the patch! I think this gets the condition slightly wrong. For a decimal number, we should promote: int -> long -> vlong. For a hex number, though, we want int -> uint -> long -> ulong -> vlong -> uvlong however with the condition above, 18446744073709551615 will get converted to a uvlong: c1 & Numvlong =3D=3D 0: false -> no explicit conversion convvtox(vv, TUVLONG) > convvtox(vv, TULONG) true -> vv fits into a uvlong, but not a ulong, so we enter this. so then, we end up in this branch: if((c1 & Numuns) || convvtox(vv, TVLONG) < 0) { true, because convvtox(vv, TVLONG) < 0. I think we want: if(c1 & Numvlong || convvtox(vv, TUVLONG) !=3D convvtox(vv, TULONG) || convvtox(vv, TLONG) < 0) { if((c1 & (Numdec|Numuns)) =3D=3D 0 && ((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 || convvtox(vv, TULONG) > convvtox(vv, TUINT) || convvtox(vv, TINT) < 0) { if((c1 & (Numdec|Numuns)) =3D=3D 0 &&=20 ((c1 & Numuns) || convvtox(vv, TLONG) < 0)) { c =3D LULCONST; t =3D TULONG; goto nret; } c =3D LLCONST; t =3D TLONG; goto nret; } ------------------------------------------ 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T22754f10b241991c-M4a92d= 1c5d54d32d3f8221d1e Delivery options: https://9fans.topicbox.com/groups/9fans/subscription