[LLVMbugs] [Bug 13884] New: initializer list in new[] for objects always calls default constructor

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Sep 20 01:42:06 PDT 2012


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

             Bug #: 13884
           Summary: initializer list in new[] for objects always calls
                    default constructor
           Product: clang
           Version: 3.0
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++11
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: jessevdk at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


I'm trying to use the following initialization (example):

struct Data
{
    float values[3];

    Data()
    :
        values({0, 0, 0})
    {
        std::cout << "Default constructor" << std::endl;
    }

    Data(float a, float b, float c)
    :
        values({a, b, c})
    {
        std::cout << "Initialization constructor" << std::endl;
    }
};

int main (int argc, char const* argv[])
{
    Data *data = new Data[1] {
        Data(0, 1, 2)
    };

    return 0;
}

Using g++ this gives the correct result (i.e. it's calling the initialization
constructor). However, using clang++ the default constructor is always called.

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