Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755027Ab3DWJA0 (ORCPT ); Tue, 23 Apr 2013 05:00:26 -0400 Received: from mx0.aculab.com ([213.249.233.131]:57519 "HELO mx0.aculab.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1754760Ab3DWJAT (ORCPT ); Tue, 23 Apr 2013 05:00:19 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Subject: RE: Unsigned widening casts of binary "not" operations.. Date: Tue, 23 Apr 2013 09:59:05 +0100 Message-ID: In-Reply-To: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Unsigned widening casts of binary "not" operations.. Thread-Index: Ac4/uYncWaABZOdZQnqoZ43QRKGmVwARvk/A References: From: "David Laight" To: "Linus Torvalds" , "Ingo Molnar" , "H. Peter Anvin" , "Thomas Gleixner" , "David Miller" , "Theodore Ts'o" Cc: "Linux Kernel Mailing List" , "the arch/x86 maintainers" , "Network Development" , Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id r3N90ZxA011544 Content-Length: 708 Lines: 13 > What happens is that the "~bitmask" is done in the *narrower* type, > and then - because the narrower type is unsigned - the cast to the > wider type is done as an *unsigned* cast, so what you *think* happens > is that it clears the bits that are set in "bitmask", but what > *actually* happens is that yes, you clear the bits that are set in > :bitmask", but you *also* clear the upper bits of value. If the narrower type is signed it is probably even more confusing! The high bits will be preserved unless you are masking off bit 31. David ????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?