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/106383] New: False positives from -Wanalyzer-va-list-exhausted Date: Thu, 21 Jul 2022 14:38:38 +0000 [thread overview] Message-ID: <bug-106383-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106383 Bug ID: 106383 Summary: False positives from -Wanalyzer-va-list-exhausted Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: analyzer Assignee: dmalcolm at gcc dot gnu.org Reporter: dmalcolm at gcc dot gnu.org Blocks: 106358 Target Milestone: --- https://godbolt.org/z/c87abh5vc Given: typedef __builtin_va_list va_list; struct printf_spec { unsigned int type; }; int format_decode(const char *fmt, struct printf_spec *spec); static int vbin_printf(const char *fmt, va_list args) { struct printf_spec spec; int width = 0; while (*fmt) { int read = format_decode(fmt, &spec); fmt += read; switch (spec.type) { case 0: break; case 1: width = __builtin_va_arg(args, int); break; } } return width; } int bprintf(const char *fmt, ...) { va_list args; int ret; __builtin_va_start(args, fmt); ret = vbin_printf(fmt, args); __builtin_va_end(args); return ret; } we get this false positive with trunk with -fanalyzer: ../../src/vsprintf.c: In function ‘vbin_printf’: ../../src/vsprintf.c:23:13: warning: ‘args’ has no more arguments (0 consumed) [CWE-685] [-Wanalyzer-va-list-exhausted] 23 | width = __builtin_va_arg(args, int); | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ‘bprintf’: events 1-2 | | 31 | int bprintf(const char *fmt, ...) { | | ^~~~~~~ | | | | | (1) entry to ‘bprintf’ |...... | 36 | ret = vbin_printf(fmt, args); | | ~~~~~~~~~~~~~~~~~~~~~~ | | | | | (2) calling ‘vbin_printf’ from ‘bprintf’ | +--> ‘vbin_printf’: events 3-6 | | 10 | static int vbin_printf(const char *fmt, va_list args) { | | ^~~~~~~~~~~ | | | | | (3) entry to ‘vbin_printf’ |...... | 14 | while (*fmt) { | | ~ | | | | | (4) following ‘true’ branch... | 15 | int read = format_decode(fmt, &spec); | | ~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | | (5) ...to here |...... | 23 | width = __builtin_va_arg(args, int); | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | | (6) ‘args’ has no more arguments (0 consumed) | Reduced from Linux kernel: lib/vsprintf.c Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106358 [Bug 106358] [meta-bug] tracker bug for building the Linux kernel with -fanalyzer
next reply other threads:[~2022-07-21 14:38 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-07-21 14:38 dmalcolm at gcc dot gnu.org [this message] 2022-07-21 18:14 ` [Bug analyzer/106383] " dmalcolm at gcc dot gnu.org 2022-07-21 21:30 ` cvs-commit at gcc dot gnu.org 2022-07-21 21:34 ` dmalcolm 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-106383-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: linkBe 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).