public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug analyzer/116304] New: False negative from -fanalyzer on "return NULL"; due to NULL being in a system header
@ 2024-08-08 23:22 dmalcolm at gcc dot gnu.org
  0 siblings, 0 replies; only message in thread
From: dmalcolm at gcc dot gnu.org @ 2024-08-08 23:22 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 116304
           Summary: False negative from -fanalyzer on "return NULL"; due
                    to NULL being in a system header
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: dmalcolm at gcc dot gnu.org
  Target Milestone: ---

gcc/testsuite/c-c++-common/analyzer/malloc-CWE-401-example.c has:

    return NULL; /* TODO: should complain that "buf" is leaked on this path. 
*/

I'm filing this bug to track that issue.

Debugging Arsen's patch
  [PATCH v2] c++: improve diagnostic of 'return's in coroutines
     https://gcc.gnu.org/pipermail/gcc-patches/2024-August/659933.html

showed that the diagnostics subsystem seems to be rejecting the diagnostic here
due to the "NULL" of return NULL being in a system header:

Breakpoint 8, diagnostic_context::report_diagnostic (this=0x4b00e80
<global_diagnostic_context>, diagnostic=0x7fffffff7d20)
    at ../../src/gcc/diagnostic.cc:1477
1477        return false;
(gdb) list
1472          && ((!m_warn_system_headers
1473               && diagnostic->m_iinfo.m_allsyslocs)
1474              || m_inhibit_warnings))
1475        /* Bail if the warning is not to be reported because all locations
in the
1476           inlining stack (if there is one) are in system headers.  */
1477        return false;
1478    
1479      if (diagnostic->kind != DK_NOTE && diagnostic->kind != DK_ICE)
1480        diagnostic_check_max_errors (this);
1481    
(gdb) list 1470
1465      /* Check to see if the diagnostic is enabled at the location and
1466         not disabled by #pragma GCC diagnostic anywhere along the inlining
1467         stack.  .  */
1468      if (!diagnostic_enabled (diagnostic))
1469        return false;
1470    
1471      if ((was_warning || diagnostic->kind == DK_WARNING)
1472          && ((!m_warn_system_headers
1473               && diagnostic->m_iinfo.m_allsyslocs)
1474              || m_inhibit_warnings))
(gdb) 
1475        /* Bail if the warning is not to be reported because all locations
in the
1476           inlining stack (if there is one) are in system headers.  */
1477        return false;
1478    
1479      if (diagnostic->kind != DK_NOTE && diagnostic->kind != DK_ICE)
1480        diagnostic_check_max_errors (this);
1481    
1482      m_lock++;
1483    
1484      if (diagnostic->kind == DK_ICE || diagnostic->kind == DK_ICE_NOBT)
(gdb) p was_warning
$8 = true
(gdb) p m_warn_system_headers
$9 = false
(gdb) p diagnostic->m_iinfo.m_allsyslocs
$10 = true

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-08-08 23:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-08 23:22 [Bug analyzer/116304] New: False negative from -fanalyzer on "return NULL"; due to NULL being in a system header 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).