From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lx5G4-00042w-4y for qemu-devel@nongnu.org; Thu, 23 Apr 2009 16:10:56 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lx5Fz-0003zu-9u for qemu-devel@nongnu.org; Thu, 23 Apr 2009 16:10:55 -0400 Received: from [199.232.76.173] (port=48690 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lx5Fz-0003zp-5c for qemu-devel@nongnu.org; Thu, 23 Apr 2009 16:10:51 -0400 Received: from bsdimp.com ([199.45.160.85]:62549 helo=harmony.bsdimp.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Lx5Fy-0001CY-Iz for qemu-devel@nongnu.org; Thu, 23 Apr 2009 16:10:51 -0400 Date: Thu, 23 Apr 2009 14:07:35 -0600 (MDT) Message-Id: <20090423.140735.-2001112580.imp@bsdimp.com> Subject: Re: [Qemu-devel] [7234] Use a more natural order From: "M. Warner Losh" In-Reply-To: <20090423195553.GM3795@csclub.uwaterloo.ca> References: <20090423192844.GJ3795@csclub.uwaterloo.ca> <20090423.134136.-135509976.imp@bsdimp.com> <20090423195553.GM3795@csclub.uwaterloo.ca> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: lsorense@csclub.uwaterloo.ca Cc: blauwirbel@gmail.com, qemu-devel@nongnu.org In message: <20090423195553.GM3795@csclub.uwaterloo.ca> lsorense@csclub.uwaterloo.ca (Lennart Sorensen) writes: : > I've fixed several bugs like this over the years from coders that : > thought this was a good way to program. : > : > if (1 < x) : > : > rather than : > : > if (x < 1) : > : > is the most common pattern I've had to fix. : : Then you were fixing the wrong problem. The problem isn't the order, : but simply that sometimes people get their logic backwards. The correct : fix would have been: : : if (1 > x) : : if in fact the logic was backwards. No. My fix was the correct one. :) : > I find this argument unpersuasive when the compiler will already warn : > me about if (x = 0). : : Some compilers warn you. Not all do. An error from all compilers is : also far better than a warning from some compilers. In the absence of other side effects, yes. : This is why people writing safety critical code in C require this order. : It is simply the safest choice. It isn't the safest order. It is safer for one class of expressions, more dangerous for the others. I've also never seen that requirement in any of the works that I've done, which has had safety implications... Warner