From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Gdlhc-0006by-2Z for qemu-devel@nongnu.org; Sat, 28 Oct 2006 06:46:12 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GdlhY-0006aj-G5 for qemu-devel@nongnu.org; Sat, 28 Oct 2006 06:46:11 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GdlhY-0006ag-AW for qemu-devel@nongnu.org; Sat, 28 Oct 2006 06:46:08 -0400 Received: from [64.233.162.205] (helo=nz-out-0102.google.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GdlhX-0007v0-Be for qemu-devel@nongnu.org; Sat, 28 Oct 2006 06:46:07 -0400 Received: by nz-out-0102.google.com with SMTP id 9so1108101nzo for ; Sat, 28 Oct 2006 03:46:06 -0700 (PDT) Message-ID: <56d259a00610280346j5b88de07p203dd6f82c3543c2@mail.gmail.com> Date: Sat, 28 Oct 2006 11:46:05 +0100 From: "Martin Guy" Sender: martinwguy@gmail.com Subject: Re: [Qemu-devel] [PATCH] Fix char signedness In-Reply-To: <20061027.122311.-365734984.imp@bsdimp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20061027.122311.-365734984.imp@bsdimp.com> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: schwab@suse.de > gcc on ARM systems default to unsigned. The C standard specifically > states that char is either signed or unsigned at the whim of the > implementor Or, more to the point, at the behest of the machine architecture. Having to generate code to sign-extend the hard way every time you do char-integer promotion if the hardware doesn't do it automatically would be long and inefficient, specially since it happens all the time. This has been a problem since the "All the world's a VAX" days, the classic boob being char c; while ((c = getchar()) != EOF) { ... } of course, 255 always != -1 so it loops forever. Check how many of your C primers get this wrong! The flipside of that boob is that on a signed char architecture, the loop will exit prematurely when it meets a 255 character. These days instead, all the world's a 386 and anything different is broken... 24-bit integers, anyone? :) M