From: Jeff King <peff@peff.net>
To: Johannes Schindelin <johannes.schindelin@gmx.de>
Cc: Stefan Beller <sbeller@google.com>,
Michael Blume <blume.mike@gmail.com>,
peter@lekensteyn.nl, eungjun.yi@navercorp.com,
Git List <git@vger.kernel.org>
Subject: Re: Git compile warnings (under mac/clang)
Date: Thu, 22 Jan 2015 17:01:40 -0500 [thread overview]
Message-ID: <20150122220140.GB6695@peff.net> (raw)
In-Reply-To: <b2cbad0d8e59a0c4eb0565608f3f90bc@www.dscho.org>
On Thu, Jan 22, 2015 at 10:20:01PM +0100, Johannes Schindelin wrote:
> On 2015-01-22 20:59, Stefan Beller wrote:
> > cc Johannes Schindelin <Johannes.Schindelin@gmx.de> who is working in
> > the fsck at the moment
> >
> > On Thu, Jan 22, 2015 at 11:43 AM, Michael Blume <blume.mike@gmail.com> wrote:
> >
> >> CC fsck.o
> >> fsck.c:110:38: warning: comparison of unsigned enum expression >= 0 is
> >> always true [-Wtautological-compare]
> >> if (options->msg_severity && msg_id >= 0 && msg_id < FSCK_MSG_MAX)
> >> ~~~~~~ ^ ~
>
> According to A2.5.4 of The C Programming Language 2nd edition:
>
> Identifiers declared as enumerators (see Par.A.8.4) are constants of type int.
>
> Therefore, the warning is incorrect: any assumption about enum fsck_msg_id to be unsigned is false.
I'm not sure that made it to ANSI. C99 says (setion 6.7.2.2, paragraph
4):
Each enumerated type shall be compatible with char, a signed integer
type, or an unsigned integer type. The choice of type is
implementation-defined, but shall be capable of representing the
values of all the members of the enumeration.
I don't have a copy of C89, but this isn't mentioned in the (very
cursory) list of changes found in C99. Anyway, that's academic.
I think we dealt with a similar situation before, in
3ce3ffb840a1dfa7fcbafa9309fab37478605d08.
-Peff
next prev parent reply other threads:[~2015-01-22 22:01 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-22 19:43 Git compile warnings (under mac/clang) Michael Blume
2015-01-22 19:59 ` Stefan Beller
2015-01-22 21:19 ` Peter Wu
2015-01-22 21:20 ` Johannes Schindelin
2015-01-22 22:01 ` Jeff King [this message]
2015-01-23 11:48 ` Johannes Schindelin
2015-01-23 12:23 ` Jeff King
2015-01-23 12:38 ` Johannes Schindelin
2015-01-23 13:30 ` Jeff King
2015-01-23 18:07 ` Junio C Hamano
2015-01-23 18:37 ` Jeff King
2015-01-23 18:46 ` Johannes Schindelin
2015-01-23 18:55 ` Jeff King
2015-01-23 19:20 ` Johannes Schindelin
2015-01-23 18:48 ` Junio C Hamano
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=20150122220140.GB6695@peff.net \
--to=peff@peff.net \
--cc=blume.mike@gmail.com \
--cc=eungjun.yi@navercorp.com \
--cc=git@vger.kernel.org \
--cc=johannes.schindelin@gmx.de \
--cc=peter@lekensteyn.nl \
--cc=sbeller@google.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).