public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug analyzer/109251] New: -Wanalyzer-deref-before-check false positives seen in Linux kernel due to check in macros
@ 2023-03-22 14:10 dmalcolm at gcc dot gnu.org
  2024-02-16 14:04 ` [Bug analyzer/109251] [13/14 Regression] " dmalcolm at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2023-03-22 14:10 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109251
           Summary: -Wanalyzer-deref-before-check false positives seen in
                    Linux kernel due to check in macros
           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 54734
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54734&action=edit
Reduced reproducer

The attached triggers a false positive from -Wanalyzer-deref-before-check:

https://godbolt.org/z/TsrnedsWP

<source>: In function 'sched_slice':
<source>:50:25: warning: check of 'se' for NULL after already dereferencing it
[-Wanalyzer-deref-before-check]
   50 |   for_each_sched_entity(se) {
      |                         ^~
<source>:32:10: note: in definition of macro 'for_each_sched_entity'
   32 |   for (; se; se = NULL)
      |          ^~
  'sched_slice': event 1
    |
    |   48 |   slice = __sched_period(nr_running + !se->on_rq);
    |      |                                        ~~^~~~~~~
    |      |                                          |
    |      |                                          (1) pointer 'se' is
dereferenced here
    |
  'sched_slice': event 2
    |
    |   50 |   for_each_sched_entity(se) {
    |      |                         ^~
    |      |                         |
    |      |                         (2) pointer 'se' is checked for NULL here
but it was already dereferenced at (1)
<source>:32:10: note: in definition of macro 'for_each_sched_entity'
    |   32 |   for (; se; se = NULL)
    |      |          ^~
    |

Looks similar to PR 108745, but that one's marked as fixed, whereas this one is
still firing.

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

end of thread, other threads:[~2024-05-09 17:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-22 14:10 [Bug analyzer/109251] New: -Wanalyzer-deref-before-check false positives seen in Linux kernel due to check in macros dmalcolm at gcc dot gnu.org
2024-02-16 14:04 ` [Bug analyzer/109251] [13/14 Regression] " dmalcolm at gcc dot gnu.org
2024-03-04 13:00 ` rguenth at gcc dot gnu.org
2024-03-08 15:37 ` law at gcc dot gnu.org
2024-03-20 22:34 ` cvs-commit at gcc dot gnu.org
2024-03-20 22:39 ` [Bug analyzer/109251] [13 " dmalcolm at gcc dot gnu.org
2024-05-09 17:12 ` cvs-commit at gcc dot gnu.org
2024-05-09 17:50 ` [Bug analyzer/109251] " dmalcolm 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).