Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1946421AbXBIMjD (ORCPT ); Fri, 9 Feb 2007 07:39:03 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1946428AbXBIMjC (ORCPT ); Fri, 9 Feb 2007 07:39:02 -0500 Received: from javad.com ([216.122.176.236]:4038 "EHLO javad.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1946421AbXBIMjA (ORCPT ); Fri, 9 Feb 2007 07:39:00 -0500 From: Sergei Organov To: Linus Torvalds Cc: "J.A. =?utf-8?B?TWFnYWxsw4PCs24=?=" , Jan Engelhardt , Jeff Garzik , Linux Kernel Mailing List , Andrew Morton Subject: Re: somebody dropped a (warning) bomb References: <45CB3B28.60102@garzik.org> <20070208221317.5beedaeb@werewolf-wl> Date: Fri, 09 Feb 2007 15:38:39 +0300 In-Reply-To: (Linus Torvalds's message of "Thu, 8 Feb 2007 14:03:06 -0800 (PST)") Message-ID: <87abznsdyo.fsf@javad.com> User-Agent: Gnus/5.110006 (No Gnus v0.6) XEmacs/21.4.19 (linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1829 Lines: 46 Linus Torvalds writes: > On Thu, 8 Feb 2007, Linus Torvalds wrote: >> >> But THE CALLER CANNOT AND MUST NOT CARE! Because the sign of "char" is >> implementation-defined, so if you call "strcmp()", you are already >> basically saying: I don't care (and I _cannot_ care) what sign you are >> using. > > Let me explain it another way. > > Say you use > > signed char *myname, *yourname; > > if (strcmp(myname,yourname) < 0) > printf("Ha, I win!\n") > > and you compile this on an architecture where "char" is signed even > without the explicit "signed". As far as I can read the C99 standard, the "char", "signed char", and "unsigned char", are all different types: "The three types char, signed char, and unsigned char are collectively called the character types. The implementation shall define char to have the same range, representation, and behavior as either signed char or unsigned char.(35) .... (35) CHAR_MIN, defined in , will have one of the values 0 or SCHAR_MIN, and this can be used to distinguish the two options. Irrespective of the choice made, char is a separate type ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ from the other two and is not compatible with either. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ " If so, then the code above is broken no matter what representation of "char" is chosen for given arch, as strcmp() takes "char*" arguments, that are not compatible with either "signed char*" or "unsigned char*". -- Sergei. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/