Topic: Does 12.2/4 (Temporary Objects) contradict itself?
Author: =?iso-8859-1?q?Daniel_Kr=FCgler?= <daniel.kruegler@googlemail.com>
Date: Wed, 23 May 2007 00:23:47 CST Raw View
On 22 Mai, 18:12, hofm...@anvil-soft.com ("Matthias Hofmann") wrote:
> I am a little puzzled about 12.2/4, because it seems to contradict itself:
> "In that context, the temporary that holds the result of the expression
> shall persist until the object's initialization is complete. [...] the
> temporary is destroyed after it has been copied, BEFORE or when the
> initialization completes." (emphasize mine)
>
> Apart from the mysterious requirement of a copy of the temporary being
> created and the possibility of the copy constructor being called many times,
> I wonder how the temporary can be destroyed earlier if it is supposed to
> persist until the initialization is complete?
According to the *closed* issue
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#117
the meaning has of *before* to be interpreted that it refers to the
case in which some part of the initialization terminates by throwing
an exception.
Nevertheless the whole paragraph has been drastically reworked
due to defect report
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#201
which also fixes
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#124
The most recent wording (N2284) is given by the following
"There are two contexts in which temporaries are destroyed at a
different point than the end of the full-expression. The first
context
is when a default constructor is called to initialize an element of
an
array. If the constructor has one or more default arguments, the
destruction of every temporary created in a default argument
expression is sequenced before the construction of the next array
element, if any."
Greetings from Bremen,
Daniel Kr gler
---
[ 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.comeaucomputing.com/csc/faq.html ]
Author: hofmann@anvil-soft.com ("Matthias Hofmann")
Date: Tue, 22 May 2007 16:12:14 GMT Raw View
Hello everyone,
I am a little puzzled about 12.2/4, because it seems to contradict itself:
"In that context, the temporary that holds the result of the expression
shall persist until the object's initialization is complete. [...] the
temporary is destroyed after it has been copied, BEFORE or when the
initialization completes." (emphasize mine)
Apart from the mysterious requirement of a copy of the temporary being
created and the possibility of the copy constructor being called many times,
I wonder how the temporary can be destroyed earlier if it is supposed to
persist until the initialization is complete?
--
Matthias Hofmann
Anvil-Soft, CEO
http://www.anvil-soft.com - The Creators of Toilet Tycoon
http://www.anvil-soft.de - Die Macher des Klomanagers
---
[ 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.comeaucomputing.com/csc/faq.html ]
Author: AlbertoBarbati@libero.it (Alberto Ganesh Barbati)
Date: Tue, 22 May 2007 20:52:44 GMT Raw View
Matthias Hofmann ha scritto:
> Hello everyone,
>
> I am a little puzzled about 12.2/4, because it seems to contradict itself:
> "In that context, the temporary that holds the result of the expression
> shall persist until the object's initialization is complete. [...] the
> temporary is destroyed after it has been copied, BEFORE or when the
> initialization completes." (emphasize mine)
>
> Apart from the mysterious requirement of a copy of the temporary being
> created and the possibility of the copy constructor being called many times,
> I wonder how the temporary can be destroyed earlier if it is supposed to
> persist until the initialization is complete?
>
The paragraph is defective. See issue CWG #201:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2264.html#201
HTH,
Ganesh
---
[ 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.comeaucomputing.com/csc/faq.html ]