https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109120
Bug ID: 109120 Summary: False positive -Wanalyzer-malloc-leak with failed iconv_open() Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: analyzer Assignee: dmalcolm at gcc dot gnu.org Reporter: urs at akk dot org Target Milestone: --- Host: x86_64-pc-linux-gnu Target: x86_64-pc-linux-gnu Build: x86_64-pc-linux-gnu Created attachment 54660 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54660&action=edit minimal test case gcc build from git @ a9835599fdb56f33da23e4514a9e21d8c2d51d71 with configure --program-suffix=-13 --enable-languages=c,lto --enable-lto --disable-multilib --enable-default-pie make -j 12 BOOT_CFLAGS='-pipe -O0 -w' bootstrap on x86_64-pc-linux-gnu (AMD Ryzen 7 PRO 6850U); Debian GNU/Linux 12 (bookworm); Kernel 6.1.0-4-amd64; GLIBC 2.36-8 gcc-13 -v -save-temps -freport-bug -g -std=c11 -O0 -fanalyzer -c iconv.c -o iconv results in iconv.c: In function ‘t’: iconv.c:11:5: warning: leak of ‘cd’ [CWE-401] [-Wanalyzer-malloc-leak] 11 | return; | ^~~~~~ ‘t’: events 1-2 | | 8 | if ((cd = iconv_open("From", "To")) != (iconv_t) (-1)) { | | ~ ^~~~~~~~~~~~~~~~~~~~~~~~ | | | | | | | (1) allocated here | | (2) following ‘false’ branch (when ‘cd == 18446744073709551615’)... | ‘t’: event 3 | |cc1: | (3): ...to here | ‘t’: event 4 | | 11 | return; | | ^~~~~~ | | | | | (4) ‘cd’ leaks here; was allocated at (1) |