Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756761Ab3DWP0I (ORCPT ); Tue, 23 Apr 2013 11:26:08 -0400 Received: from mx0.aculab.com ([213.249.233.131]:37681 "HELO mx0.aculab.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1756758Ab3DWP0G (ORCPT ); Tue, 23 Apr 2013 11:26:06 -0400 Content-class: urn:content-classes:message Subject: RE: Unsigned widening casts of binary "not" operations.. MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Date: Tue, 23 Apr 2013 16:24:33 +0100 Message-ID: In-Reply-To: X-MimeOLE: Produced By Microsoft Exchange V6.5 X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Unsigned widening casts of binary "not" operations.. Thread-Index: Ac5ALs8w5qoe3bp8SBuK5Vkhno/mjQABy1eQ References: From: "David Laight" To: "Linus Torvalds" Cc: "Ingo Molnar" , "H. Peter Anvin" , "Thomas Gleixner" , "David Miller" , "Theodore Ts'o" , "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 r3NFQX8W013713 Content-Length: 631 Lines: 18 > > 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. > > Yes. However, that case doesn't trigger with the normal case of small > values. So "~4" works fine with widening, in a way that "~4u" does > not. Thinks ... converting: foo &= ~bar; to: foo = ~(~foo | bar); would generally DTRT. Whether the compiler has the relevant patterns to optimise it is another question. David ????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?