(ref.doc)clamage 140395
Next ark 140395
Prev: horstman 140395
Up: Usenet
Newsgroups: comp.std.c++
Subject: Re: switch and lifetime of temporaries
Date: 14 Mar 1995 23:40:47 GMT
>Can anyone point me at some more detailed information stating exactly
>what the proposed standard specifies on lifetime of temporaries?
The latest decision of the C++ Committee (last year sometime) is that
temporaries are destroyed at the end of the full-expression in which
they are created (unless bound to a reference). A "full-expression" is
an expression which is not part of any other expression. Not all compilers
implement this rule yet, and may follow the old rule. The old rule
allowed destroying the temp at any time up to the end of the block.
It should not be possible to write well-formed code in which a temporary
is destroyed which was not created. Either the compiler did not catch
an error in the code, or the compiler did not properly keep track of
its temporaries. (The compiler is not required to catch all errors in
code; some constructs have undefined behavior and allowing your program
to crash is one alternative open to the compiler.)
To be fair, keeping track of the temps is very difficult,
and most compilers have historically had bugs in that area.
automatically generated by info2www version 1.2.2.8