From mboxrd@z Thu Jan 1 00:00:00 1970 From: erik quanstrom Date: Wed, 16 Jun 2010 11:26:55 -0400 To: maht-9fans@maht0x0r.net, 9fans@9fans.net Message-ID: <9013d88b6219f01a48b8fee28a2b5d6c@coraid.com> In-Reply-To: <4C18D1D8.2060301@maht0x0r.net> References: <4C18D1D8.2060301@maht0x0r.net> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] portability question Topicbox-Message-UUID: 345adb16-ead6-11e9-9d60-3106f5b1d025 > check the ASM, looks like c is being cast as signed and then sign > extended into a long and then ORed with l. > > perhaps this would solve it : > > l |= ((unsigned long) c) << 24 that works. the extra () are unnecessary. i think that gcc is using 6.3.1.1 and converting c to an int (since it fits) so the original expression is evaulated as (int)0xab << (int)24 -> (int)0xab000000 if there is any sign extension here, it is shifted away. then gcc sign-extends this into 8 bytes, giving the value you see. - erik