Topic: defect 178 : initialisation in new expression ?
Author: AlbertoBarbati@libero.it (Alberto Barbati)
Date: Mon, 13 Sep 2004 16:52:44 GMT Raw View
news user wrote:
> IIUC issue:
> http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#178
> then POD's created by means of a new expression will be
> zero-initialised? Would'nt this incur a performance penalty?
>
If you write
POD* p = new POD();
it will be value-initialized (that is, for a POD without user-declared
default ctor, it will be zero-initialized).
Instead, if you write
POD* p = new POD;
it will not be initialized.
So can have both behaviours, the choice is yours.
Alberto
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: ark@acm.org ("Andrew Koenig")
Date: Tue, 14 Sep 2004 04:05:51 GMT Raw View
"news user" <news@sisyphus.news.be.easynet.net> wrote in message
news:4145884a$0$10705$6c56d894@feed0.news.be.easynet.net...
> IIUC issue:
> http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#178
> then POD's created by means of a new expression will be zero-initialised?
> Would'nt this incur a performance penalty?
PODs created by a new expression are not zero-initialized unless you put a
pair of parentheses after the type.
Example:
int* p = new int; // not initialized
int* q = new int(0); // explicitly initialized to 0
int* r = new int(); // implicitly initialized to 0
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: news@sisyphus.news.be.easynet.net (news user)
Date: Tue, 14 Sep 2004 05:29:42 GMT Raw View
Andrew Koenig wrote:
> "news user" <news@sisyphus.news.be.easynet.net> wrote in message
> news:4145884a$0$10705$6c56d894@feed0.news.be.easynet.net...
>
>>IIUC issue:
>>http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#178
>>then POD's created by means of a new expression will be zero-initialised?
>>Would'nt this incur a performance penalty?
>
>
> PODs created by a new expression are not zero-initialized unless you put a
> pair of parentheses after the type.
>
Now I found where my confusion comes from: the proposed resolution for
paragraph 5.3.4.15 says first "in the first subitem of the first
item..." and next "in the second item ....". Isupposed that this 'second
iterm' referred to the 'second _sub_item' and therefore was totally
confused.
Sorry for the misunderstanding.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: news@sisyphus.news.be.easynet.net (news user)
Date: Mon, 13 Sep 2004 12:17:02 GMT Raw View
IIUC issue: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#178
then POD's created by means of a new expression will be
zero-initialised? Would'nt this incur a performance penalty?
toon
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]