[LLVMbugs] [Bug 7948] New: Explicitly initialized arrays with fewer initializers than elements don't value initialize remaining elements

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Aug 20 03:14:16 PDT 2010


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

           Summary: Explicitly initialized arrays with fewer initializers
                    than elements don't value initialize remaining
                    elements
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: chandlerc at gmail.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


% cat t.cc                      
struct S { const int x; };

const S good[2] = { { 42 }, { } };
const S bad[2] = { { 42 } };

% ./bin/clang -fsyntax-only t.cc
t.cc:1:8: error: implicit default constructor for 'S' must explicitly
initialize the const member 'x'
struct S { const int x; };
       ^
t.cc:1:22: note: declared here
struct S { const int x; };
                     ^
t.cc:4:18: note: implicit default constructor for 'S' first required here
const S bad[2] = { { 42 } };
                 ^
1 error generated.


As far as I can tell 'good' and 'bad' should be initialized exactly the same
way: value initialized. Specifically, C++03 [dcl.init.aggr] 8.5.1/7 says: "If
there are fewer initializers in the list than there are members in the
aggregate, then each member not explicitly initialized shall be
value-initialized (8.5)." It looks like the remaining elements are being
default initialized instead of value initialized.

-- 
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