public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug analyzer/109131] New: -Wanalyzer-deref-before-check false positive seen in git's builtin/show-ref.c
@ 2023-03-14 19:30 dmalcolm at gcc dot gnu.org
  2023-10-27 17:50 ` [Bug analyzer/109131] " alexey.lapshin at espressif dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2023-03-14 19:30 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109131
           Summary: -Wanalyzer-deref-before-check false positive seen in
                    git's builtin/show-ref.c
           Product: gcc
           Version: 13.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 54664
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54664&action=edit
Reduced reproducer

Trunk erroneously emits:

deref-before-check-git-show-ref.c: In function 'cmd_show_ref':
deref-before-check-git-show-ref.c:39:8: warning: check of 'argv' for NULL after
already dereferencing it [-Wanalyzer-deref-before-check]
   39 |     if (!pattern)
      |        ^
  'cmd_show_ref': events 1-8
    |
    |   31 |   if (exclude_arg)
    |      |      ^
    |      |      |
    |      |      (1) following 'false' branch...
    |......
    |   34 |   pattern = argv;
    |      |   ~~~~~~~~~~~~~~
    |      |           |
    |      |           (2) ...to here
    |   35 |   if (!*pattern)
    |      |      ~ ~~~~~~~~
    |      |      | |
    |      |      | (3) pointer 'argv' is dereferenced here
    |      |      (4) following 'false' branch...
    |......
    |   38 |   if (verify) {
    |      |      ~~~~~~~
    |      |      ||
    |      |      |(5) ...to here
    |      |      (6) following 'true' branch...
    |   39 |     if (!pattern)
    |      |        ~~~~~~~~~
    |      |        ||
    |      |        |(7) ...to here
    |      |        (8) pointer 'argv' is checked for NULL here but it was
already dereferenced at (3)
    |

on the attached.

https://godbolt.org/z/oW4hvqx7K

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-05-21  9:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-14 19:30 [Bug analyzer/109131] New: -Wanalyzer-deref-before-check false positive seen in git's builtin/show-ref.c dmalcolm at gcc dot gnu.org
2023-10-27 17:50 ` [Bug analyzer/109131] " alexey.lapshin at espressif dot com
2024-02-15 19:56 ` [Bug analyzer/109131] [13/14 Regression] " dmalcolm at gcc dot gnu.org
2024-03-04 13:00 ` rguenth at gcc dot gnu.org
2024-03-08 15:38 ` law at gcc dot gnu.org
2024-05-21  9:14 ` [Bug analyzer/109131] [13/14/15 " jakub at gcc dot gnu.org

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).