Activity log for bug #1648852

Date Who What changed Old value New value Message
2016-12-09 16:53:54 Bob Miller bug added bug
2016-12-09 16:53:54 Bob Miller attachment added source file https://bugs.launchpad.net/bugs/1648852/+attachment/4789649/+files/init-bug.c
2016-12-09 16:55:17 Bob Miller description The combination of union with anonymous struct member and initializer with statement function containing a declaration causes a spurious "missing initializer for field" warning. I am using arm-none-eabi-gcc 5.4.1 20160919. I am using the project-compiled binaries. The bug is also present in 4.9.3 20141119 and 5.2.1 20151202. Host machine is MacOS 10.11.6. Transcript: ~$ cat > init-bug.c union gfx_point { struct { float x, y; }; }; union gfx_point line_p0; void animate(void) { line_p0 = (union gfx_point) { #ifdef NO_ERROR .x = ({ 0; }), #else .x = ({ float z = 0; z; }), #endif .y = 0, }; } ~$ arm-none-eabi-gcc --version arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 5.4.1 20160919 (release) [ARM/embedded-5-branch revision 240496] Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ~$ arm-none-eabi-gcc -Wextra -c -std=c11 init-bug.c init-bug.c: In function 'animate': init-bug.c:20:9: warning: missing initializer for field 'y' of 'struct <anonymous>' [-Wmissing-field-initializers] .y = 0, ^ init-bug.c:3:18: note: 'y' declared here float x, y; ^ ~$ arm-none-eabi-gcc -Wextra -c -std=c11 init-bug.c -DNO_ERROR ~$ The combination of union with anonymous struct member and initializer with statement expression containing a declaration causes a spurious "missing initializer for field" warning. I am using arm-none-eabi-gcc 5.4.1 20160919. I am using the project-compiled binaries. The bug is also present in 4.9.3 20141119 and 5.2.1 20151202. Host machine is MacOS 10.11.6. Transcript: ~$ cat > init-bug.c union gfx_point {     struct {         float x, y;     }; }; union gfx_point line_p0; void animate(void) {     line_p0 = (union gfx_point) { #ifdef NO_ERROR         .x = ({ 0; }), #else         .x = ({             float z = 0;             z;         }), #endif         .y = 0,     }; } ~$ arm-none-eabi-gcc --version arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 5.4.1 20160919 (release) [ARM/embedded-5-branch revision 240496] Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ~$ arm-none-eabi-gcc -Wextra -c -std=c11 init-bug.c init-bug.c: In function 'animate': init-bug.c:20:9: warning: missing initializer for field 'y' of 'struct <anonymous>' [-Wmissing-field-initializers]          .y = 0,          ^ init-bug.c:3:18: note: 'y' declared here          float x, y;                   ^ ~$ arm-none-eabi-gcc -Wextra -c -std=c11 init-bug.c -DNO_ERROR ~$