public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-2301] libcpp: Make static checkers happy about makeuname2c [PR106778]
Date: Wed, 31 Aug 2022 08:25:28 +0000 (GMT)	[thread overview]
Message-ID: <20220831082528.0933B3850432@sourceware.org> (raw)

https://gcc.gnu.org/g:b3048b6ffb126a4624f66bad713fe6d1dc6dc13d

commit r13-2301-gb3048b6ffb126a4624f66bad713fe6d1dc6dc13d
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Aug 31 10:22:36 2022 +0200

    libcpp: Make static checkers happy about makeuname2c [PR106778]
    
    The assertion ensures that we point within the image and at a byte
    we haven't touched yet (or at least that it isn't the first byte
    of an already stored tree), some static checker was unhappy about
    first checking that it is zero and only afterwards checking that it
    is within bounds.
    
    2022-08-31  Jakub Jelinek  <jakub@redhat.com>
    
            PR preprocessor/106778
            * makeuname2c.cc (write_nodes): Reverse order of && operands in
            assert.

Diff:
---
 libcpp/makeuname2c.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcpp/makeuname2c.cc b/libcpp/makeuname2c.cc
index f27e010dc6e..2b3c7085314 100644
--- a/libcpp/makeuname2c.cc
+++ b/libcpp/makeuname2c.cc
@@ -451,7 +451,7 @@ write_nodes (struct node *n, size_t off)
 {
   for (; n; n = n->sibling)
     {
-      assert (tree[off] == 0 && off < tree_size);
+      assert (off < tree_size && tree[off] == 0);
       if (n->key_len > 1)
 	{
 	  assert (n->key_len < 64);

                 reply	other threads:[~2022-08-31  8:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220831082528.0933B3850432@sourceware.org \
    --to=jakub@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).