public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dmalcolm at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug analyzer/113314] New: -Wanalyzer-infinite-loop false positive seen on haproxy's fd.c
Date: Wed, 10 Jan 2024 20:42:15 +0000	[thread overview]
Message-ID: <bug-113314-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113314

            Bug ID: 113314
           Summary: -Wanalyzer-infinite-loop false positive seen on
                    haproxy's fd.c
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: dmalcolm at gcc dot gnu.org
  Target Milestone: ---

Created attachment 57027
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57027&action=edit
Reproducer

https://godbolt.org/z/1oYYear8z

t.c: In function ‘fd_add_to_fd_list’:
t.c:71:15: warning: infinite loop [CWE-835] [-Wanalyzer-infinite-loop]
   71 |   next = fdtab[fd].update.next;
      |               ^
  ‘fd_add_to_fd_list’: events 1-5
    |
    |   71 |   next = fdtab[fd].update.next;
    |      |               ^
    |      |               |
    |      |               (1) infinite loop here
    |   72 |   if (next > -2)
    |      |      ~         
    |      |      |
    |      |      (2) if it ever follows ‘false’ branch, it will always do
so...
    |   73 |     goto done;
    |   74 |   if (next == -2)
    |      |      ~         
    |      |      |
    |      |      (3) ...to here
    |      |      (4) if it ever follows ‘true’ branch, it will always do so...
    |   75 |     goto redo_next;
    |      |     ~~~~       
    |      |     |
    |      |     (5) ...to here
    |
  ‘fd_add_to_fd_list’: event 6
    |
    |cc1:
    | (6): looping back...
    |
  ‘fd_add_to_fd_list’: event 7
    |
    |   71 |   next = fdtab[fd].update.next;
    |      |               ^
    |      |               |
    |      |               (7) ...to here

Seen on haproxy-2.7.1's src/fd.c (in analyzer integration tests).

             reply	other threads:[~2024-01-10 20:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-10 20:42 dmalcolm at gcc dot gnu.org [this message]
2024-01-10 22:01 ` [Bug analyzer/113314] " dmalcolm at gcc dot gnu.org
2024-02-16 13:54 ` [Bug analyzer/113314] [14 Regression] " dmalcolm at gcc dot gnu.org
2024-03-04 13:05 ` rguenth at gcc dot gnu.org
2024-03-07 20:51 ` law at gcc dot gnu.org
2024-03-25 16:12 ` dmalcolm at gcc dot gnu.org
2024-03-25 18:40 ` pinskia at gcc dot gnu.org
2024-05-07  7:43 ` [Bug analyzer/113314] [14/15 " rguenth at gcc dot gnu.org

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=bug-113314-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).