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]

Re: Initialization with new[]


> I thought that 'new T[n] (arg list)' was gcc extension (useful!). I read
> that there are only technical limitations on using this synatx. Is it
> right?

I think this is the case. gcc -pedantic says, on Alexey's revised
example:

a.cc:11: warning: ANSI C++ forbids declaration `main' with no type
a.cc: In function `int main()':
a.cc:12: warning: initialization in array new
a.cc:15: warning: initialization in array new

I question whether that extension is particularly useful, though.

Especially in the case of an integer array, there is a clean
standard-conforming solution: write a loop, assigning each element.
It is absolutely portable, and it is as efficient as anything the
compiler could come up with.

Regards,
Martin


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