This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Initialization with new[]


Dear GCC developers,

Why I can not initialize array of int[] with operator new?
This is example:

#include <iostream>
int main(void)
{
  int *a = new int    (1);   // initialize *a with 1
  int *b = new int[2] (1);   // initialize each element with 1
  cout << *a << "  " << b[0] << endl;
}

The output is:
1  0

So b[] is not initialized. Is it correct?

With best wishes,
Alexander Zvyagin.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]