https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118194
Bug ID: 118194 Summary: spurious warning with -Wmaybe-uninitialized Product: gcc Version: 14.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: sshannin at gmail dot com Target Milestone: --- There are a number of other open bug reports about this warning, but none of them seemed quite the same. This is different in that: - doesn't rely on C++ constructs such as lambdas - occurs at all optimization levels -O0 through -O3 - very simple path with no control flow #include <stdlib.h> #include <sys/mman.h> void *foo(int sz) { void *p = malloc(sz); mlock(p, sz); return p; } The above minimal example triggers a maybe-uninitialized warning: <source>: In function 'foo': <source>:6:5: warning: 'p' may be used uninitialized [-Wmaybe-uninitialized] 6 | mlock(p, sz); | ^~~~~~~~~~~~ In file included from <source>:2: /usr/include/x86_64-linux-gnu/sys/mman.h:103:12: note: by argument 1 of type 'const void *' to 'mlock' declared here 103 | extern int mlock (const void *__addr, size_t __len) __THROW; | ^~~~~ It looks like this was introduced starting in 11.1 and is present up through trunk.