1 // { dg-do run { xfail *-*-* } } 2 // XFAILed until PR2123 is fixed 3 // PR 11228: array operator new, with zero-initialization and a variable sized array. 4 // Regression test for PR 5 // Author: Matt Austern <austern@apple.com> 6 7 8 #include <new> 9 #include <stdlib.h> 10 #include <string.h> 11 allocate(int n)12int* allocate(int n) 13 { 14 void *p; 15 p = malloc(n * sizeof (int)); 16 memset (p, 0xff, n * sizeof(int)); 17 return new (p) int[n](); 18 } 19 main()20int main() 21 { 22 const int n = 17; 23 int* p = allocate(n); 24 for (int i = 0; i < n; ++i) 25 if (p[i] != 0) 26 abort (); 27 exit (0); 28 } 29