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/110172] New: Leak false positives from -fanalyzer with -fexceptions (even on C code)
Date: Thu, 08 Jun 2023 13:39:08 +0000	[thread overview]
Message-ID: <bug-110172-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 110172
           Summary: Leak false positives from -fanalyzer with -fexceptions
                    (even on C code)
           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: ---

As noted by Reddit user "kr90df" here:
https://www.reddit.com/r/C_Programming/comments/13wl8qi/improvements_to_static_analysis_in_the_gcc_13/jndkr80/
we get a false +ve from -Wanalyzer-va-list-leak on this C code when
-fexceptions is enabled:

#include <stdio.h>
#include <stdarg.h>

int printerr(char *msg, ...) 
{ 
    va_list ap;
    va_start(ap, msg);
    vfprintf(stderr, msg, ap);
    va_end(ap);

    return(-1);
}

See https://godbolt.org/z/zrxsrYE4j

<source>: In function 'printerr':
<source>:12:1: warning: missing call to 'va_end' [-Wanalyzer-va-list-leak]
   12 | }
      | ^
  'printerr': events 1-2
    |
    |    7 |     va_start(ap, msg);
    |      |     ^~~~~~~~
    |      |     |
    |      |     (1) 'va_start' called here
    |......
    |   12 | }
    |      | ~    
    |      | |
    |      | (2) missing call to 'va_end' to match 'va_start' at (1)
    |

             reply	other threads:[~2023-06-08 13:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-08 13:39 dmalcolm at gcc dot gnu.org [this message]
2023-06-20 14:43 ` [Bug analyzer/110172] " dmalcolm at gcc dot gnu.org
2023-06-20 15:35 ` xry111 at gcc dot gnu.org
2023-06-20 15:40 ` redi at gcc dot gnu.org
2023-06-20 15:46 ` xry111 at gcc dot gnu.org
2023-06-20 15:58 ` fw 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-110172-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).