Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > new A v.s. new A()

Reply
Thread Tools

new A v.s. new A()

 
 
Greg Comeau
Guest
Posts: n/a
 
      06-28-2003
In article <>,
Victor Bazarov <> wrote:
>"Ron Natalie" <> wrote...
>> "Yu Cao" <> wrote in message

>news:bdfvj6$pgq$...
>> > Q2. For a POD type, is operator new[] allowed to take non-default
>> > initializers? Example:
>> >
>> > int* p = new int[100](1); // LINE AA

>>
>> What you wrote above is illegal for ANY type.
>> >
>> > Q3. For a POD type, should the following two statements both perform
>> > zero initialization:
>> >
>> > int *p = new int[100]; // LINE BB
>> > int *p = new int[100](); // LINE CC

>>
>> The latter is ILLEGAL.

>
>Really? How would you explain that it works in Comeau? Another
>"****ed-up Comeau extension"?


Just so there is no confusion, I labelled the above statements.
LINE BB and LINE CC are both valid, legal, and well-defined,
and usually mean different things. LINE AA is not allowed.
--
Greg Comeau/ 4.3.0.1: FULL CORE LANGUAGE, INCLUDING TC1
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      06-28-2003
"Ron Natalie" <> wrote...
>
> "Victor Bazarov" <> wrote in message

news:...
>
> > > The default constructor (whether user defined or not) is
> > > called in both cases like for a definition "A a;" right?

> >
> > If it's not defined ("trivial"), how would it be called?
> >

> As far as the standard is concerend it behaves as if one was automatically
> inserted by the compiler.


How can one verify that "as if"? There is no code to put
the breakpoint or a debugging output statement, is there?
That's what my question was about.


 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      06-28-2003
"Greg Comeau" <> wrote in message
news:bdir76$shh$...
> In article <>,
> Victor Bazarov <> wrote:
> >"Ron Natalie" <> wrote...
> >> "Yu Cao" <> wrote in message

> >news:bdfvj6$pgq$...
> >> > Q2. For a POD type, is operator new[] allowed to take non-default
> >> > initializers? Example:
> >> >
> >> > int* p = new int[100](1); // LINE AA
> >>
> >> What you wrote above is illegal for ANY type.
> >> >
> >> > Q3. For a POD type, should the following two statements both perform
> >> > zero initialization:
> >> >
> >> > int *p = new int[100]; // LINE BB
> >> > int *p = new int[100](); // LINE CC
> >>
> >> The latter is ILLEGAL.

> >
> >Really? How would you explain that it works in Comeau? Another
> >"****ed-up Comeau extension"?

>
> Just so there is no confusion, I labelled the above statements.
> LINE BB and LINE CC are both valid, legal, and well-defined,
> and usually mean different things. LINE AA is not allowed.


The whole idea for my "Really" was to coerce Ron into looking it
up in the Standard in an attempt to make him substantiate his
claims. It has become customary here (in response to some newbies'
"it works this way here so it's right" statements) to actually
quote the Standard (not that it has the desired effect every time),
so I would expect both Ron and you not to use "it's legal" or "it's
ILLEGAL" without proof. And, mind you, *I* don't need that proof,
most of the time. It's the other posters who read the forum I am
concerned about.

Victor



 
Reply With Quote
 
Ron Natalie
Guest
Posts: n/a
 
      06-30-2003

"Victor Bazarov" <> wrote in message news:VHhLa.41883$Fy6.12552@sccrnsc03...

>
> How can one verify that "as if"? There is no code to put
> the breakpoint or a debugging output statement, is there?
> That's what my question was about.
>


Debugging is not part of the language.
The constructor is treated AS IF it exists. Whether the compiler
emits code or calls it is an implementation detail. Read 12.1/5
and 12.1/7



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript new-new-new-new-newbee weblinkunlimited@gmail.com Javascript 2 03-11-2008 01:15 AM
2008 new year,2008 new business, 2008 new life, much cheap andbeautiful product will help you yhnetstore@gmail.com Digital Photography 0 01-07-2008 04:57 PM
New computer, New OS, New Wireless Problem :-\ =?Utf-8?B?RGFu?= Wireless Networking 3 07-31-2005 02:11 PM
[Firefox] Use New Tab instead of New Window? paul j Firefox 7 04-07-2005 09:40 PM
Why can not register a new .net passport or a new hotmail account Alick Lv MCSD 1 01-04-2004 06:12 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57