From unknown Sun Jun 22 07:49:31 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7203: [PATCH] sort: fix unportable conversion of unsigned char * -> char * Resent-From: Paul Eggert Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 12 Oct 2010 20:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 7203 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: patch To: 7203@debbugs.gnu.org X-Debbugs-Original-To: Bug-coreutils Received: via spool by submit@debbugs.gnu.org id=B.128691409215226 (code B ref -1); Tue, 12 Oct 2010 20:09:02 +0000 Received: (at submit) by debbugs.gnu.org; 12 Oct 2010 20:08:12 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P5l8u-0003xX-HP for submit@debbugs.gnu.org; Tue, 12 Oct 2010 16:08:12 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P5l8s-0003xR-C3 for submit@debbugs.gnu.org; Tue, 12 Oct 2010 16:08:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P5lBX-00085F-74 for submit@debbugs.gnu.org; Tue, 12 Oct 2010 16:11:38 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:60929) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P5lBS-00083X-NB for submit@debbugs.gnu.org; Tue, 12 Oct 2010 16:10:55 -0400 Received: from [140.186.70.92] (port=33726 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P5lAt-0000ci-8M for bug-coreutils@gnu.org; Tue, 12 Oct 2010 16:10:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P5l13-0006N7-Nd for bug-coreutils@gnu.org; Tue, 12 Oct 2010 16:00:06 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:49756) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P5l13-0006Lv-DZ for bug-coreutils@gnu.org; Tue, 12 Oct 2010 16:00:05 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 1C84D39E80E1 for ; Tue, 12 Oct 2010 13:00:04 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Qs9qY+E0GS6j for ; Tue, 12 Oct 2010 13:00:03 -0700 (PDT) Received: from [131.179.64.200] (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 9990B39E80DC for ; Tue, 12 Oct 2010 13:00:03 -0700 (PDT) Message-ID: <4CB4BE43.9030302@cs.ucla.edu> Date: Tue, 12 Oct 2010 13:00:03 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.12) Gecko/20100915 Thunderbird/3.0.8 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -5.1 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.2 (-----) This is another portability bug caught by the Sun C compiler. Without this patch, cc complains: "sort.c", line 3933: warning: assignment type mismatch: pointer to const char "=" pointer to unsigned char * src/sort.c (fold_toupper): Change this back from char to unsigned char, fixing a regression introduced in commit 59e2e55d0f154a388adc9bac37d2b45f2ba971f8 dated February 26, as the C Standard doesn't let you convert from unsigned char * to char * without a cast, and the (in theory more portable) style here is to convert char values, not pointer values. (getmonth): Convert char to unsigned char when needed for comparison. --- src/sort.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sort.c b/src/sort.c index 89f7be3..c155eda 100644 --- a/src/sort.c +++ b/src/sort.c @@ -268,7 +268,7 @@ static bool nonprinting[UCHAR_LIM]; static bool nondictionary[UCHAR_LIM]; /* Translation table folding lower case to upper. */ -static unsigned char fold_toupper[UCHAR_LIM]; +static char fold_toupper[UCHAR_LIM]; #define MONTHS_PER_YEAR 12 @@ -1952,12 +1952,12 @@ getmonth (char const *month, char **ea) *ea = (char *) m; return monthtab[ix].val; } - if (fold_toupper[to_uchar (*m)] < to_uchar (*n)) + if (to_uchar (fold_toupper[to_uchar (*m)]) < to_uchar (*n)) { hi = ix; break; } - else if (fold_toupper[to_uchar (*m)] > to_uchar (*n)) + else if (to_uchar (fold_toupper[to_uchar (*m)]) > to_uchar (*n)) { lo = ix + 1; break; -- 1.7.2 From unknown Sun Jun 22 07:49:31 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7203: [PATCH] sort: fix unportable conversion of unsigned char * -> char * Resent-From: Jim Meyering Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 12 Oct 2010 21:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7203 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: patch To: Paul Eggert Cc: 7203@debbugs.gnu.org Received: via spool by 7203-submit@debbugs.gnu.org id=B7203.128691869717381 (code B ref 7203); Tue, 12 Oct 2010 21:25:01 +0000 Received: (at 7203) by debbugs.gnu.org; 12 Oct 2010 21:24:57 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P5mLA-0004WI-UN for submit@debbugs.gnu.org; Tue, 12 Oct 2010 17:24:57 -0400 Received: from mx.meyering.net ([82.230.74.64]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P5mL8-0004WD-O5 for 7203@debbugs.gnu.org; Tue, 12 Oct 2010 17:24:55 -0400 Received: by rho.meyering.net (Acme Bit-Twister, from userid 1000) id 615D4DD0B; Tue, 12 Oct 2010 23:28:22 +0200 (CEST) From: Jim Meyering In-Reply-To: <4CB4BE43.9030302@cs.ucla.edu> (Paul Eggert's message of "Tue, 12 Oct 2010 13:00:03 -0700") References: <4CB4BE43.9030302@cs.ucla.edu> Date: Tue, 12 Oct 2010 23:28:22 +0200 Message-ID: <87mxqj5ceh.fsf@meyering.net> Lines: 57 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -5.3 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.3 (-----) Paul Eggert wrote: > This is another portability bug caught by the Sun C compiler. > Without this patch, cc complains: > > "sort.c", line 3933: warning: assignment type mismatch: > pointer to const char "=" pointer to unsigned char > > > * src/sort.c (fold_toupper): Change this back from char to > unsigned char, fixing a regression introduced in commit > 59e2e55d0f154a388adc9bac37d2b45f2ba971f8 dated February 26, as the > C Standard doesn't let you convert from unsigned char * to char * > without a cast, and the (in theory more portable) style here is to > convert char values, not pointer values. > (getmonth): Convert char to unsigned char when needed for > comparison. Calling commit 59e2e55d0f a regression might lead the unwary to think that it causes sort to malfunction, when in fact, at worst (afaics), it evokes a warning. So how about something like s/regression/problem/ ? This feels like enough of a technicality that I'd prefer to defer it. > --- > src/sort.c | 6 +++--- > 1 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/src/sort.c b/src/sort.c > index 89f7be3..c155eda 100644 > --- a/src/sort.c > +++ b/src/sort.c > @@ -268,7 +268,7 @@ static bool nonprinting[UCHAR_LIM]; > static bool nondictionary[UCHAR_LIM]; > > /* Translation table folding lower case to upper. */ > -static unsigned char fold_toupper[UCHAR_LIM]; > +static char fold_toupper[UCHAR_LIM]; > > #define MONTHS_PER_YEAR 12 > > @@ -1952,12 +1952,12 @@ getmonth (char const *month, char **ea) > *ea = (char *) m; > return monthtab[ix].val; > } > - if (fold_toupper[to_uchar (*m)] < to_uchar (*n)) > + if (to_uchar (fold_toupper[to_uchar (*m)]) < to_uchar (*n)) > { > hi = ix; > break; > } > - else if (fold_toupper[to_uchar (*m)] > to_uchar (*n)) > + else if (to_uchar (fold_toupper[to_uchar (*m)]) > to_uchar (*n)) > { > lo = ix + 1; > break; From unknown Sun Jun 22 07:49:31 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7203: [PATCH] sort: fix unportable conversion of unsigned char * -> char * Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 12 Oct 2010 21:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7203 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: patch To: Jim Meyering Cc: 7203@debbugs.gnu.org, Paul Eggert Received: via spool by 7203-submit@debbugs.gnu.org id=B7203.128692037118159 (code B ref 7203); Tue, 12 Oct 2010 21:53:01 +0000 Received: (at 7203) by debbugs.gnu.org; 12 Oct 2010 21:52:51 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P5mmA-0004iq-OU for submit@debbugs.gnu.org; Tue, 12 Oct 2010 17:52:51 -0400 Received: from mail1.slb.deg.dub.stisp.net ([84.203.253.98]) by debbugs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1P5mm8-0004il-HZ for 7203@debbugs.gnu.org; Tue, 12 Oct 2010 17:52:49 -0400 Received: (qmail 64823 invoked from network); 12 Oct 2010 21:56:15 -0000 Received: from unknown (HELO ?192.168.2.25?) (84.203.137.218) by mail1.slb.deg.dub.stisp.net with SMTP; 12 Oct 2010 21:56:15 -0000 Message-ID: <4CB4D911.8020409@draigBrady.com> Date: Tue, 12 Oct 2010 22:54:25 +0100 From: =?UTF-8?Q?P=C3=A1draig?= Brady User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 MIME-Version: 1.0 References: <4CB4BE43.9030302@cs.ucla.edu> <87mxqj5ceh.fsf@meyering.net> In-Reply-To: <87mxqj5ceh.fsf@meyering.net> X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.7 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.7 (--) On 12/10/10 22:28, Jim Meyering wrote: > Paul Eggert wrote: >> This is another portability bug caught by the Sun C compiler. >> Without this patch, cc complains: >> >> "sort.c", line 3933: warning: assignment type mismatch: >> pointer to const char "=" pointer to unsigned char >> >> >> * src/sort.c (fold_toupper): Change this back from char to >> unsigned char, fixing a regression introduced in commit >> 59e2e55d0f154a388adc9bac37d2b45f2ba971f8 dated February 26, as the >> C Standard doesn't let you convert from unsigned char * to char * >> without a cast, and the (in theory more portable) style here is to >> convert char values, not pointer values. >> (getmonth): Convert char to unsigned char when needed for >> comparison. > > Calling commit 59e2e55d0f a regression might lead the unwary > to think that it causes sort to malfunction, when in fact, > at worst (afaics), it evokes a warning. > > So how about something like s/regression/problem/ ? > > This feels like enough of a technicality that I'd prefer to defer it. Note gcc would also warn about this with -Wall, except that we disable the warning with -Wno-pointer-sign in configure.ac So I agree with the change, but s/regression/warning/ cheers, Pádraig. From unknown Sun Jun 22 07:49:31 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7203: [PATCH] sort: fix unportable conversion of unsigned char * -> char * Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 12 Oct 2010 22:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7203 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: patch To: Jim Meyering Cc: 7203@debbugs.gnu.org, Paul Eggert Received: via spool by 7203-submit@debbugs.gnu.org id=B7203.128692177118759 (code B ref 7203); Tue, 12 Oct 2010 22:17:02 +0000 Received: (at 7203) by debbugs.gnu.org; 12 Oct 2010 22:16:11 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P5n8l-0004sW-2v for submit@debbugs.gnu.org; Tue, 12 Oct 2010 18:16:11 -0400 Received: from mail1.slb.deg.dub.stisp.net ([84.203.253.98]) by debbugs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1P5n8i-0004sR-DQ for 7203@debbugs.gnu.org; Tue, 12 Oct 2010 18:16:09 -0400 Received: (qmail 68347 invoked from network); 12 Oct 2010 22:19:35 -0000 Received: from unknown (HELO ?192.168.2.25?) (84.203.137.218) by mail1.slb.deg.dub.stisp.net with SMTP; 12 Oct 2010 22:19:35 -0000 Message-ID: <4CB4DE89.8020300@draigBrady.com> Date: Tue, 12 Oct 2010 23:17:45 +0100 From: =?UTF-8?Q?P=C3=A1draig?= Brady User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 MIME-Version: 1.0 References: <4CB4BE43.9030302@cs.ucla.edu> <87mxqj5ceh.fsf@meyering.net> <4CB4D911.8020409@draigBrady.com> In-Reply-To: <4CB4D911.8020409@draigBrady.com> X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.7 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.7 (--) On 12/10/10 22:54, Pádraig Brady wrote: > On 12/10/10 22:28, Jim Meyering wrote: >> Paul Eggert wrote: >>> This is another portability bug caught by the Sun C compiler. >>> Without this patch, cc complains: >>> >>> "sort.c", line 3933: warning: assignment type mismatch: >>> pointer to const char "=" pointer to unsigned char >>> >>> >>> * src/sort.c (fold_toupper): Change this back from char to >>> unsigned char, fixing a regression introduced in commit >>> 59e2e55d0f154a388adc9bac37d2b45f2ba971f8 dated February 26, as the >>> C Standard doesn't let you convert from unsigned char * to char * >>> without a cast, and the (in theory more portable) style here is to >>> convert char values, not pointer values. >>> (getmonth): Convert char to unsigned char when needed for >>> comparison. >> >> Calling commit 59e2e55d0f a regression might lead the unwary >> to think that it causes sort to malfunction, when in fact, >> at worst (afaics), it evokes a warning. >> >> So how about something like s/regression/problem/ ? >> >> This feels like enough of a technicality that I'd prefer to defer it. > > Note gcc would also warn about this with -Wall, except that > we disable the warning with -Wno-pointer-sign in configure.ac > > So I agree with the change, but s/regression/warning/ I just compiled coreutils/{src,lib} with make CFLAGS="-Wpointer-sign -Werror" and the above was the only issue. How about enabling the warning? commit e6d6fd6ecfce79b8c3f1e4ce7da67b26adbfbb82 Author: Pádraig Brady Date: Tue Oct 12 23:15:23 2010 +0100 maint: enable the -Wpointer-sign gcc warning * configure.ac: -Wall implicit enables this warning so remove the explicit disabling. diff --git a/configure.ac b/configure.ac index acd397e..7ebf98c 100644 --- a/configure.ac +++ b/configure.ac @@ -98,7 +98,6 @@ if test "$gl_gcc_warnings" = yes; then done gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now - gl_WARN_ADD([-Wno-pointer-sign]) # Too many warnings for now gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now # In spite of excluding -Wlogical-op above, it is enabled, as of From unknown Sun Jun 22 07:49:31 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7203: [PATCH] sort: fix unportable conversion of unsigned char * -> char * Resent-From: Paul Eggert Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 12 Oct 2010 23:20:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7203 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: patch To: Jim Meyering Cc: 7203@debbugs.gnu.org Received: via spool by 7203-submit@debbugs.gnu.org id=B7203.128692559620473 (code B ref 7203); Tue, 12 Oct 2010 23:20:03 +0000 Received: (at 7203) by debbugs.gnu.org; 12 Oct 2010 23:19:56 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P5o8S-0005KA-G6 for submit@debbugs.gnu.org; Tue, 12 Oct 2010 19:19:56 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P5o8P-0005K3-1k for 7203@debbugs.gnu.org; Tue, 12 Oct 2010 19:19:54 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id DBA6D39E80E1; Tue, 12 Oct 2010 16:23:20 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id h2+dqeb2o0yO; Tue, 12 Oct 2010 16:23:20 -0700 (PDT) Received: from [131.179.64.200] (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 7286839E80DB; Tue, 12 Oct 2010 16:23:20 -0700 (PDT) Message-ID: <4CB4EDE7.8000906@cs.ucla.edu> Date: Tue, 12 Oct 2010 16:23:19 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.12) Gecko/20100915 Thunderbird/3.0.8 MIME-Version: 1.0 References: <4CB4BE43.9030302@cs.ucla.edu> <87mxqj5ceh.fsf@meyering.net> In-Reply-To: <87mxqj5ceh.fsf@meyering.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam-Score: -3.5 (---) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.5 (---) On 10/12/10 14:28, Jim Meyering wrote: > This feels like enough of a technicality that I'd prefer to defer it. Well, my suspicion is that some C compilers simply refuse to compile the construct, as they're entitled to do. I vaguely recall that happening in the past. No big deal of course. You're right about the word "regression": I should have called it a "warning" or "compile-time issue" or something like that, since it's not a run-time problem on all practical porting hosts. From unknown Sun Jun 22 07:49:31 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7203: [PATCH] sort: fix unportable conversion of unsigned char * -> char * Resent-From: Jim Meyering Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Wed, 13 Oct 2010 04:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7203 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: patch To: Paul Eggert Cc: 7203@debbugs.gnu.org Received: via spool by 7203-submit@debbugs.gnu.org id=B7203.128694381228361 (code B ref 7203); Wed, 13 Oct 2010 04:24:02 +0000 Received: (at 7203) by debbugs.gnu.org; 13 Oct 2010 04:23:32 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P5ssF-0007NN-La for submit@debbugs.gnu.org; Wed, 13 Oct 2010 00:23:31 -0400 Received: from mx.meyering.net ([82.230.74.64]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P5ssC-0007NI-T6 for 7203@debbugs.gnu.org; Wed, 13 Oct 2010 00:23:29 -0400 Received: by rho.meyering.net (Acme Bit-Twister, from userid 1000) id D3C57E29F; Wed, 13 Oct 2010 06:26:56 +0200 (CEST) From: Jim Meyering In-Reply-To: <4CB4EDE7.8000906@cs.ucla.edu> (Paul Eggert's message of "Tue, 12 Oct 2010 16:23:19 -0700") References: <4CB4BE43.9030302@cs.ucla.edu> <87mxqj5ceh.fsf@meyering.net> <4CB4EDE7.8000906@cs.ucla.edu> Date: Wed, 13 Oct 2010 06:26:56 +0200 Message-ID: <87hbgq67lb.fsf@meyering.net> Lines: 17 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -5.3 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.3 (-----) Paul Eggert wrote: > On 10/12/10 14:28, Jim Meyering wrote: >> This feels like enough of a technicality that I'd prefer to defer it. > > Well, my suspicion is that some C compilers simply refuse to compile > the construct, as they're entitled to do. I vaguely recall that > happening in the past. No big deal of course. Could well be. If fixing this decreases by one the number of bug reports, then it'll have been worth applying, and I can think of at least one test-system-menagerie where it may well affect several. So go ahead and push that after all. > You're right about the word "regression": I should have called it a "warning" > or "compile-time issue" or something like that, since it's not a run-time > problem on all practical porting hosts. From unknown Sun Jun 22 07:49:31 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7203: [PATCH] sort: fix unportable conversion of unsigned char * -> char * Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 16 Nov 2010 00:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7203 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: patch To: Jim Meyering Cc: 7203@debbugs.gnu.org, Paul Eggert Received: via spool by 7203-submit@debbugs.gnu.org id=B7203.128986812620115 (code B ref 7203); Tue, 16 Nov 2010 00:43:02 +0000 Received: (at 7203) by debbugs.gnu.org; 16 Nov 2010 00:42:06 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PI9cb-0005EM-TM for submit@debbugs.gnu.org; Mon, 15 Nov 2010 19:42:06 -0500 Received: from mail1.slb.deg.dub.stisp.net ([84.203.253.98]) by debbugs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1PI9cW-0005E0-F1 for 7203@debbugs.gnu.org; Mon, 15 Nov 2010 19:42:04 -0500 Received: (qmail 39935 invoked from network); 16 Nov 2010 00:46:57 -0000 Received: from unknown (HELO ?192.168.2.25?) (84.203.137.218) by mail1.slb.deg.dub.stisp.net with SMTP; 16 Nov 2010 00:46:57 -0000 Message-ID: <4CE1D461.8070000@draigBrady.com> Date: Tue, 16 Nov 2010 00:46:25 +0000 From: =?UTF-8?Q?P=C3=A1draig?= Brady User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 MIME-Version: 1.0 References: <4CB4BE43.9030302@cs.ucla.edu> <87mxqj5ceh.fsf@meyering.net> <4CB4D911.8020409@draigBrady.com> <4CB4DE89.8020300@draigBrady.com> In-Reply-To: <4CB4DE89.8020300@draigBrady.com> X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.7 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.7 (--) On 12/10/10 23:17, Pádraig Brady wrote: > On 12/10/10 22:54, Pádraig Brady wrote: >> On 12/10/10 22:28, Jim Meyering wrote: >>> Paul Eggert wrote: >>>> This is another portability bug caught by the Sun C compiler. >>>> Without this patch, cc complains: >>>> >>>> "sort.c", line 3933: warning: assignment type mismatch: >>>> pointer to const char "=" pointer to unsigned char >>>> >>>> >>>> * src/sort.c (fold_toupper): Change this back from char to >>>> unsigned char, fixing a regression introduced in commit >>>> 59e2e55d0f154a388adc9bac37d2b45f2ba971f8 dated February 26, as the >>>> C Standard doesn't let you convert from unsigned char * to char * >>>> without a cast, and the (in theory more portable) style here is to >>>> convert char values, not pointer values. >>>> (getmonth): Convert char to unsigned char when needed for >>>> comparison. >>> >>> Calling commit 59e2e55d0f a regression might lead the unwary >>> to think that it causes sort to malfunction, when in fact, >>> at worst (afaics), it evokes a warning. >>> >>> So how about something like s/regression/problem/ ? >>> >>> This feels like enough of a technicality that I'd prefer to defer it. >> >> Note gcc would also warn about this with -Wall, except that >> we disable the warning with -Wno-pointer-sign in configure.ac >> >> So I agree with the change, but s/regression/warning/ > > I just compiled coreutils/{src,lib} with make CFLAGS="-Wpointer-sign -Werror" > and the above was the only issue. How about enabling the warning? > > commit e6d6fd6ecfce79b8c3f1e4ce7da67b26adbfbb82 > Author: Pádraig Brady > Date: Tue Oct 12 23:15:23 2010 +0100 > > maint: enable the -Wpointer-sign gcc warning > > * configure.ac: -Wall implicit enables this warning > so remove the explicit disabling. > > diff --git a/configure.ac b/configure.ac > index acd397e..7ebf98c 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -98,7 +98,6 @@ if test "$gl_gcc_warnings" = yes; then > done > gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one > gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now > - gl_WARN_ADD([-Wno-pointer-sign]) # Too many warnings for now > gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now > > # In spite of excluding -Wlogical-op above, it is enabled, as of > > > > I just applied that and this follow up commit 0d1ba34494e5e5e21e205f2e86349afeb69ca84d Author: Pádraig Brady Date: Tue Nov 16 00:31:05 2010 +0000 maint: fix a new -Wpointer-sign gcc warning * src/csplit.c (max_out): Fix a new warning introduced with commit 6568b173, 2010-11-10, "csplit: do not rely on..." diff --git a/src/csplit.c b/src/csplit.c index 531e492..07c5c8c 100644 --- a/src/csplit.c +++ b/src/csplit.c @@ -1275,7 +1275,7 @@ max_out (char *format) error (EXIT_FAILURE, 0, _("too many %% conversion specifications in suffix")); percent = true; - unsigned int flags; + int flags; f += get_format_flags (f, &flags); while (ISDIGIT (*f)) f++; From unknown Sun Jun 22 07:49:31 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.427 (Entity 5.427) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Paul Eggert Subject: bug#7203: closed (Re: bug#7203: [PATCH] sort: fix unportable conversion of unsigned char * -> char *) Message-ID: References: <874o5u3ehf.fsf@rho.meyering.net> <4CB4BE43.9030302@cs.ucla.edu> X-Gnu-PR-Message: they-closed 7203 X-Gnu-PR-Package: coreutils X-Gnu-PR-Keywords: patch Reply-To: 7203@debbugs.gnu.org Date: Tue, 19 Apr 2011 07:09:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1303196942-31266-1" This is a multi-part message in MIME format... ------------=_1303196942-31266-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #7203: [PATCH] sort: fix unportable conversion of unsigned char * -> char * which was filed against the coreutils package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 7203@debbugs.gnu.org. --=20 7203: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D7203 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1303196942-31266-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 7203-done) by debbugs.gnu.org; 19 Apr 2011 07:08:37 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QC536-00087a-BR for submit@debbugs.gnu.org; Tue, 19 Apr 2011 03:08:36 -0400 Received: from mx.meyering.net ([82.230.74.64]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QC534-00087N-52 for 7203-done@debbugs.gnu.org; Tue, 19 Apr 2011 03:08:34 -0400 Received: by rho.meyering.net (Acme Bit-Twister, from userid 1000) id 9CD80600FB; Tue, 19 Apr 2011 09:08:28 +0200 (CEST) From: Jim Meyering To: Paul Eggert Subject: Re: bug#7203: [PATCH] sort: fix unportable conversion of unsigned char * -> char * In-Reply-To: <4CB4BE43.9030302@cs.ucla.edu> (Paul Eggert's message of "Tue, 12 Oct 2010 13:00:03 -0700") References: <4CB4BE43.9030302@cs.ucla.edu> Date: Tue, 19 Apr 2011 09:08:28 +0200 Message-ID: <874o5u3ehf.fsf@rho.meyering.net> Lines: 19 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -5.9 (-----) X-Debbugs-Envelope-To: 7203-done Cc: 7203-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.9 (-----) Paul Eggert wrote: > This is another portability bug caught by the Sun C compiler. > Without this patch, cc complains: > > "sort.c", line 3933: warning: assignment type mismatch: > pointer to const char "=" pointer to unsigned char > > > * src/sort.c (fold_toupper): Change this back from char to > unsigned char, fixing a regression introduced in commit > 59e2e55d0f154a388adc9bac37d2b45f2ba971f8 dated February 26, as the > C Standard doesn't let you convert from unsigned char * to char * > without a cast, and the (in theory more portable) style here is to > convert char values, not pointer values. > (getmonth): Convert char to unsigned char when needed for > comparison. Thanks again. The patch went in months ago, so I'm closing this. ------------=_1303196942-31266-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 12 Oct 2010 20:08:12 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P5l8u-0003xX-HP for submit@debbugs.gnu.org; Tue, 12 Oct 2010 16:08:12 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P5l8s-0003xR-C3 for submit@debbugs.gnu.org; Tue, 12 Oct 2010 16:08:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P5lBX-00085F-74 for submit@debbugs.gnu.org; Tue, 12 Oct 2010 16:11:38 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:60929) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P5lBS-00083X-NB for submit@debbugs.gnu.org; Tue, 12 Oct 2010 16:10:55 -0400 Received: from [140.186.70.92] (port=33726 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P5lAt-0000ci-8M for bug-coreutils@gnu.org; Tue, 12 Oct 2010 16:10:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P5l13-0006N7-Nd for bug-coreutils@gnu.org; Tue, 12 Oct 2010 16:00:06 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:49756) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P5l13-0006Lv-DZ for bug-coreutils@gnu.org; Tue, 12 Oct 2010 16:00:05 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 1C84D39E80E1 for ; Tue, 12 Oct 2010 13:00:04 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Qs9qY+E0GS6j for ; Tue, 12 Oct 2010 13:00:03 -0700 (PDT) Received: from [131.179.64.200] (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 9990B39E80DC for ; Tue, 12 Oct 2010 13:00:03 -0700 (PDT) Message-ID: <4CB4BE43.9030302@cs.ucla.edu> Date: Tue, 12 Oct 2010 13:00:03 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.12) Gecko/20100915 Thunderbird/3.0.8 MIME-Version: 1.0 To: Bug-coreutils Subject: [PATCH] sort: fix unportable conversion of unsigned char * -> char * Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -5.1 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.2 (-----) This is another portability bug caught by the Sun C compiler. Without this patch, cc complains: "sort.c", line 3933: warning: assignment type mismatch: pointer to const char "=" pointer to unsigned char * src/sort.c (fold_toupper): Change this back from char to unsigned char, fixing a regression introduced in commit 59e2e55d0f154a388adc9bac37d2b45f2ba971f8 dated February 26, as the C Standard doesn't let you convert from unsigned char * to char * without a cast, and the (in theory more portable) style here is to convert char values, not pointer values. (getmonth): Convert char to unsigned char when needed for comparison. --- src/sort.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sort.c b/src/sort.c index 89f7be3..c155eda 100644 --- a/src/sort.c +++ b/src/sort.c @@ -268,7 +268,7 @@ static bool nonprinting[UCHAR_LIM]; static bool nondictionary[UCHAR_LIM]; /* Translation table folding lower case to upper. */ -static unsigned char fold_toupper[UCHAR_LIM]; +static char fold_toupper[UCHAR_LIM]; #define MONTHS_PER_YEAR 12 @@ -1952,12 +1952,12 @@ getmonth (char const *month, char **ea) *ea = (char *) m; return monthtab[ix].val; } - if (fold_toupper[to_uchar (*m)] < to_uchar (*n)) + if (to_uchar (fold_toupper[to_uchar (*m)]) < to_uchar (*n)) { hi = ix; break; } - else if (fold_toupper[to_uchar (*m)] > to_uchar (*n)) + else if (to_uchar (fold_toupper[to_uchar (*m)]) > to_uchar (*n)) { lo = ix + 1; break; -- 1.7.2 ------------=_1303196942-31266-1--