[llvm-bugs] [Bug 32002] New: std::make_shared does not perform zero initialization

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Feb 18 03:49:02 PST 2017


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

            Bug ID: 32002
           Summary: std::make_shared does not perform zero initialization
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: FreeBSD
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: martin.beran at kernun.cz
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

On FreeBSD 10.3, the following program displays "123", but "0" is expected:

#include <memory>
#include <iostream>

int main()
{
    std::make_shared<int>(123);
    std::cout << *std::make_shared<int>();
    return 0;
}

The second std::make_shared reuses the piece of memory of the first one. But it
should initialize it to zero, as if "new (ptr) int()" is called, where ptr is
the address of allocated memory.

-- 
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/20170218/b3c5fb1c/attachment.html>


More information about the llvm-bugs mailing list