Topic: Behavior of new operator with zero argument ????
Author: ssc@netcom.com (Shyam Chintalapati)
Date: Fri, 19 Aug 1994 02:59:31 GMT Raw View
hi there,
I am confused about the behavior of the operator 'new', when it is passed
an argument of zero.
*** [1] On page 59 of the ARM (Section 5.3.3) it is said:
"This implies that an operator new() can be called with the argument zero.
In this case, a pointer to an object is returned. Repeated such calls return
pointers to distinct objects."
Example: blah .. blah...
*** [2] Now on page 280 of ARM (Section 12.5), it is said:
"If operator new () cannot allocate storage or if it is called with the argument
0 it will return 0.
I tried the given example on page 59 with CenterLine C++ compiler,
found that it confirms to the example. So, i am confused about what
exactly the second statement means. Can somebody help?
Thanks,
-----
shyam
Author: allen@ariel.com (Marc L. Allen)
Date: 19 Aug 1994 13:55:23 GMT Raw View
Shyam Chintalapati (ssc@netcom.com) wrote:
> hi there,
> I am confused about the behavior of the operator 'new', when it is passed
> an argument of zero.
> *** [1] On page 59 of the ARM (Section 5.3.3) it is said:
> "This implies that an operator new() can be called with the argument zero.
> In this case, a pointer to an object is returned. Repeated such calls return
> pointers to distinct objects."
> Example: blah .. blah...
> *** [2] Now on page 280 of ARM (Section 12.5), it is said:
> "If operator new () cannot allocate storage or if it is called with the argument
> 0 it will return 0.
I'm not sure which ARM you're looking at, but my $12.5 on page 280 says
"If operator new() cannot allocate storage, it will return 0."
Perhaps you have an older version?
Marc