https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89061
Bug ID: 89061 Summary: GCC 9 introduces false positive in -Wjump-misses-init Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: berrange at redhat dot com Target Milestone: --- The following demo program $ cat demo.c #include <stdlib.h> struct demo { const char *cmd; }; int main(void) { struct demo demo = {0}; if ((demo.cmd = getenv("FOO")) == NULL) { goto cleanup; } demo = (struct demo) { .cmd = "foo" }; cleanup: return 0; } Results in new false positive warnings with GCC 9 $ gcc -Wjump-misses-init -o demo demo.c demo.c: In function ‘main’: demo.c:13:5: warning: jump skips variable initialization [-Wjump-misses-init] 13 | goto cleanup; | ^~~~ demo.c:18:2: note: label ‘cleanup’ defined here 18 | cleanup: | ^~~~~~~ demo.c:16:24: note: ‘({anonymous})’ declared here 16 | demo = (struct demo) { .cmd = "foo" }; | ^ 'demo' is fully initialized at every step of the program, even taking into account the jumps. It appears to be triggered by the full struct assignment. If I change demo = (struct demo) { .cmd = "foo" }; to demo.cmd = "foo"; then it no longer triggers the false positive warning. This is seen on Fedora 30 rawhide with gcc-9.0.1-0.1.fc30.x86_64 which appears to be using a git master snapshot taken sometime on 2019/01/23.