From: Junio C Hamano <gitster@pobox.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: Fernando Gouveia Lima <fernandolimabusiness@gmail.com>,
git@vger.kernel.org, Christian Couder <chriscool@tuxfamily.org>,
stolee@gmail.com, peff@peff.net
Subject: Re: [Newcomer PATCH] log-tree.c: Supress Wsign-compare-warning
Date: Fri, 23 May 2025 09:54:14 -0700 [thread overview]
Message-ID: <xmqqy0unxo7d.fsf@gitster.g> (raw)
In-Reply-To: <aDCQWr3MBX4L7sbA@pks.im> (Patrick Steinhardt's message of "Fri, 23 May 2025 17:12:26 +0200")
Patrick Steinhardt <ps@pks.im> writes:
> I'm still not of the opinion that it is garbage. We have tons of
> locations where we mismatch integer types only because we never got a
> warning from the compiler, and these have caused multiple stack
> overflows in the past.
I know we spotted many possible overflows and wraparound in the
past, but -Wsign-compare being not about sizes but signedness, I'd
consider them more as happy accidents, rather than intended outcome.
If the code had 'a < (int)b' comparison where 'a' is 'int' and 'b'
is 'size_t' [*], the code would still be wrong, but the compiler
would not have said anything.
[*] which is what a typical "I've suppressed the compiler
warning that was annoying me" patch would do if the original
were written 'a < b'.
'a -= b' can be equally bad depending on the value range of 'b', but
it is not about -Wsign-compare and would go unreported, right?
So I think noise from -Wsign-compare are certainly not "false
positives" (in the sense that the comparisons are between signed and
unsigned---the warning option is reporting what it was asked to
report), but are not-false-but-useless positives; what they try to
catch is somehow different from what they could catch to help us.
And that is why I have been skeptical.
> I do agree though this not a good project for newcomers, as fixing those
> bugs is quite intricate overall. So we should definitely remove this
> project from the microprojects page.
Yeah, that is something I am quite certain about.
next prev parent reply other threads:[~2025-05-23 16:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-21 20:24 [Newcomer PATCH] log-tree.c: Supress Wsign-compare-warning Fernando
2025-05-21 21:08 ` Junio C Hamano
2025-05-23 15:12 ` Patrick Steinhardt
2025-05-23 15:25 ` Taylor Blau
2025-05-23 16:54 ` Junio C Hamano [this message]
2025-05-30 8:13 ` Patrick Steinhardt
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=xmqqy0unxo7d.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=chriscool@tuxfamily.org \
--cc=fernandolimabusiness@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=ps@pks.im \
--cc=stolee@gmail.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).