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