[LLVMbugs] [Bug 9801] New: clang zero-initializing what it should be value-initializing

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Apr 27 14:22:35 PDT 2011


           Summary: clang zero-initializing what it should be
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: nlewycky at google.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com

Consider this simple testcase:

  extern "C" { int printf(const char *format, ...); };

  struct Test {
    Test() : i(10) {}
    Test(int i) : i(i) {}
    int i;
    int j;

  int main() {
    Test partial[3] = { 1 };
    printf("%d %d %d\n", partial[0].i, partial[1].i, partial[2].i);

    Test empty[3] = {};
    printf("%d %d %d\n", empty[0].i, empty[1].i, empty[2].i);

This is a regression; as of r129729 it worked. The program should print "1 10
10" "10 10 10". It currently prints "1 10 10" "0 0 0".

If you shrink the array down to 2 members, the bug goes away. If you remove
private members, the bug goes away.

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