1 // { dg-do assemble } 2 // Bug: new doesn't make sure that the count is an integral value. 3 4 #include <new> 5 extern "C" int printf (const char *, ...); 6 extern "C" void *malloc (std::size_t); 7 std::size_t s; 8 new(std::size_t siz)9void * operator new (std::size_t siz) 10 #if __cplusplus <= 199711L 11 throw (std::bad_alloc) 12 #endif 13 { 14 if (s == 0) 15 s = siz; 16 else 17 s = (s != siz); 18 return malloc (siz); 19 } 20 main()21int main() 22 { 23 s = 0; 24 25 float f = 3; 26 int* b1 = new int[(int)f]; 27 int* b2 = new int[f]; // { dg-error "" } new requires integral size 28 29 return s; 30 } 31