[LLVMbugs] [Bug 12824] New: suggest braces around initialization of subobject warnings confused

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon May 14 08:52:33 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=12824

             Bug #: 12824
           Summary: suggest braces around initialization of subobject
                    warnings confused
           Product: clang
           Version: trunk
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: howarth at nitro.med.uc.edu
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Created attachment 8556
  --> http://llvm.org/bugs/attachment.cgi?id=8556
test case extracted from tools/src/IsoSurface.c in molmol-2k.2.0

I have run into a code fragment from molmol which seems to confuse
-Wmissing-braces.
The attached brackets.c produces the warning...

[MacBookPro:~] howarth% /sw/opt/llvm-3.1/bin/clang -Wall -c brackets.c
brackets.c:37:3: warning: suggest braces around initialization of subobject
[-Wmissing-braces]
  0, 3, 5, 6, {{D_0, 1}, {D_0,  2}, {D_0,  3}, {D_0,  4}},
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  {                                                      }
brackets.c:38:3: warning: suggest braces around initialization of subobject
[-Wmissing-braces]
  3, 0, 5, 1, {{D_0, 0}, {D_MZ, 4}, {D_MY, 1}, {D_PX, 2}},
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  {                                                      }
brackets.c:39:3: warning: suggest braces around initialization of subobject
[-Wmissing-braces]
  0, 3, 6, 2, {{D_0, 0}, {D_MZ, 3}, {D_PY, 2}, {D_MX, 1}},
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  {                                                      }
brackets.c:40:3: warning: suggest braces around initialization of subobject
[-Wmissing-braces]
  3, 5, 6, 7, {{D_0, 0}, {D_PX, 3}, {D_PZ, 1}, {D_PY, 4}},
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  {                                                      }
brackets.c:41:3: warning: suggest braces around initialization of subobject
[-Wmissing-braces]
  5, 0, 6, 4, {{D_0, 0}, {D_MY, 3}, {D_MX, 4}, {D_PZ, 2}}
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  {                                                      }
brackets.c:37:3: warning: suggest braces around initialization of subobject
[-Wmissing-braces]
  0, 3, 5, 6, {{D_0, 1}, {D_0,  2}, {D_0,  3}, {D_0,  4}},
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
brackets.c:36:17: warning: unused variable 'CubeEven' [-Wunused-variable]
static CubeDesc CubeEven = {
                ^
7 warnings generated.

However if I follow the hint and add these brackets, clang converts these
warnings to...

[MacBookPro:~] howarth% /sw/opt/llvm-3.1/bin/clang -Wall -c brackets2.c
brackets2.c:37:3: warning: suggest braces around initialization of subobject
[-Wmissing-braces]
 {0, 3, 5, 6, {{D_0, 1}, {D_0,  2}, {D_0,  3}, {D_0,  4}}},
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  {                                                      }
brackets2.c:38:2: warning: excess elements in struct initializer
 {3, 0, 5, 1, {{D_0, 0}, {D_MZ, 4}, {D_MY, 1}, {D_PX, 2}}},
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 warnings generated.

For the same code, FSF gcc trunk produces...

[MacBookPro:~] howarth% gcc-fsf-4.8 -Wall -c brackets.c
brackets.c:37:3: warning: missing braces around initializer [-Wmissing-braces]
   0, 3, 5, 6, {{D_0, 1}, {D_0,  2}, {D_0,  3}, {D_0,  4}},
   ^
brackets.c:37:3: warning: (near initialization for ‘CubeEven.tetA’)
[-Wmissing-braces]
   0, 3, 5, 6, {{D_0, 1}, {D_0,  2}, {D_0,  3}, {D_0,  4}},
   ^
brackets.c:36:17: warning: ‘CubeEven’ defined but not used [-Wunused-variable]
 static CubeDesc CubeEven = {
                 ^
What is the expected compiler behavior here in clang and should I open a PR for
this?
Thanks in advance for any advice.
         Jack

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list