https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70924
Bug ID: 70924
Summary: Wrong position for "warning: missing braces around
initializer [-Wmissing-braces]"
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: ch3root at openwall dot com
Target Milestone: ---
Source code:
----------------------------------------------------------------------
int main()
{
struct { int w; struct { int x, y; } ss; } s = { 1, .ss = 2, 3 };
(void)s;
}
----------------------------------------------------------------------
Results:
----------------------------------------------------------------------
$ gcc -std=c11 -pedantic -Wall -Wextra -O3 test.c && ./a.out
test.c: In function ‘main’:
test.c:3:50: warning: missing braces around initializer [-Wmissing-braces]
struct { int w; struct { int x, y; } ss; } s = { 1, .ss = 2, 3 };
^
test.c:3:50: note: (near initialization for ‘s’)
----------------------------------------------------------------------
gcc version: gcc (GCC) 7.0.0 20160502 (experimental)
I think the position of the warning should be closer to "2, 3".
For comparison:
----------------------------------------------------------------------
$ clang -std=c11 -Weverything -O3 test.c && ./a.out
test.c:3:61: warning: suggest braces around initialization of subobject
[-Wmissing-braces]
struct { int w; struct { int x, y; } ss; } s = { 1, .ss = 2, 3 };
^~~~
{ }
1 warning generated.
----------------------------------------------------------------------