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

            Bug ID: 15593
           Summary: initializaing allocated multirank arrays causes heap
                    corruption
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

first an example, build and run with or without optimizations:

int main(int argc, char *argv[])
{
    auto a = new int[3][2]; // ok
    int s = 3;  // odd numbers of s greater than 1 cause corruption
    auto b = new int[s][2]{}; // corrupted
    auto c = new int[4]; // crash
    delete[] c; // never gets here
    delete[] b; // never gets here
    delete[] a; // never gets here
    return 0;
}

It's is possible to "delete[] b" and delay the crash. I assume it's because the
next allocation that fits into the "b" space is ok, but the heap after "b" is
corrupt.  Any "malloc" will crash if that allocation will occur after "b".

Built using gcc(4.7.2-1) and the same standard library, libstdc++6 (4.7.2-22),
doesn't crash.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to