[llvm-bugs] [Bug 27613] New: Wrong end location for -Winitializer-overrides with overridden initializers

via llvm-bugs llvm-bugs at lists.llvm.org
Tue May 3 02:39:12 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=27613

            Bug ID: 27613
           Summary: Wrong end location for -Winitializer-overrides with
                    overridden initializers
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: cherepan at mccme.ru
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Source code:

----------------------------------------------------------------------
int main()
{
  struct s { int x, y; } s1 = { 1, 2 };
  struct { struct s sub; int z; } s2 = { .sub = s1, .sub = 3, 4, 5 };
  (void)s2;
}
----------------------------------------------------------------------

Results:

----------------------------------------------------------------------
$ clang -std=c11 -Weverything -O3 test.c && ./a.out
test.c:4:60: warning: subobject initialization overrides initialization of
other fields within its enclosing subobject [-Winitializer-overrides]
  struct { struct s sub; int z; } s2 = { .sub = s1, .sub = 3, 4, 5 };
                                                           ^~~~~~~~~
test.c:4:49: note: previous initialization is here
  struct { struct s sub; int z; } s2 = { .sub = s1, .sub = 3, 4, 5 };
                                                ^~
test.c:4:60: warning: suggest braces around initialization of subobject
[-Wmissing-braces]
  struct { struct s sub; int z; } s2 = { .sub = s1, .sub = 3, 4, 5 };
                                                           ^~~~
                                                           {   }
2 warnings generated.
----------------------------------------------------------------------

clang version: clang version 3.9.0 (trunk 268228)

The first warning underlines "3, 4, 5 }". I think it should underline "3, 4"
only.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160503/5ed021c7/attachment.html>


More information about the llvm-bugs mailing list