Is it possible to initialise an array of non-POD with operator new and initialiser syntax? Is it possible to initialise an array of non-POD with operator new and initialiser syntax? arrays arrays

Is it possible to initialise an array of non-POD with operator new and initialiser syntax?


This seems to be clang++ bug 15735. Declare a default constructor (making it accessible and not deleted) and the program compiles, even though the default constructor is not called:

#include <iostream>struct A{   A() { std::cout << "huh?\n"; } // or without definition, linker won't complain   A(int first, int second) { std::cout << "works fine?\n"; }};int main(){   new A[1] {{1, 2}};}

Live example

g++4.9 also accepts the OP's program without modifications.