git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Randall S. Becker" <rsbecker@nexbridge.com>
To: "'Junio C Hamano'" <gitster@pobox.com>,
	"'Ben Walton'" <bdwalton@gmail.com>
Cc: <git@vger.kernel.org>
Subject: RE: [PATCH] Use unsigned char to squash compiler warnings
Date: Wed, 4 Mar 2015 17:34:23 -0500	[thread overview]
Message-ID: <002301d056cb$5d86f5a0$1894e0e0$@nexbridge.com> (raw)
In-Reply-To: <xmqqd24o76rh.fsf@gitster.dls.corp.google.com>

>On 4 Mar 2015, Junio C Hamano Wrote:
> Sent: March 4, 2015 5:11 PM
> To: Ben Walton
> Cc: git@vger.kernel.org
> Subject: Re: [PATCH] Use unsigned char to squash compiler warnings
> 
> Ben Walton <bdwalton@gmail.com> writes:
> 
> > On Mon, Mar 2, 2015 at 8:30 PM Junio C Hamano <gitster@pobox.com>
> wrote:
> >
> >> The conversion looked good from a cursory view; I didn't check it
> >> very carefully though.
> >>
> > Yes, because of the Solaris ABI, the Studio compiler defaults char to
> > signed char.
> 
> Doesn't our beloved GCC also uses signed char when you write char?
> You keep saying that "defaults to signed char is the problem", but that
does not
> explain why those in the rest of the world outside the Solaris land do not
> encounter this problem.
> 
> 	$ cat >x.c <<\EOF
>         #include <stdio.h>
>         int main (void) {
>                 SIGNED char ch = 0xff;
>                 printf("%d\n", ch);
>                 return 0;
>         }
> 	EOF
>         $ gcc -Wall -DSIGNED= x.c && ./a.out
>         -1
>         $ gcc -Wall -DSIGNED=signed x.c && ./a.out
> 	-1
> 
> I think th problem is not Solaris uses signed char for char like everybody
else
> does ;-) but it gives a fairly useless warning to annoy people.
> 
> In any case, here is what I queued, FYI, on bw/kwset-use-unsigned topic.

Even the NonStop c99 compiler does not report a warning - and it is usually
very noisy. The default is unsigned char for c99 on this platform, and the
value interpretation is significant.

#include <stdio.h>

int main (void) {
        char ch0 = 0xff;
        signed char ch1 = 0xff;
        unsigned char ch = 0xff;
        printf("%d, %d, %d, %d, %d\n", ch0, ch, ch1, ch==ch0, ch==ch1);
        return 0;
}
255, 255, -1, 1, 0

      reply	other threads:[~2015-03-04 22:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-02 19:22 [PATCH] Use unsigned char to squash compiler warnings Ben Walton
2015-03-02 20:29 ` Junio C Hamano
     [not found]   ` <CAP30j1684A=QsA0o+zLMP70V09mFTS_MtiPZB2TrRywYK2NWWw@mail.gmail.com>
2015-03-04 22:11     ` Junio C Hamano
2015-03-04 22:34       ` Randall S. Becker [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='002301d056cb$5d86f5a0$1894e0e0$@nexbridge.com' \
    --to=rsbecker@nexbridge.com \
    --cc=bdwalton@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).