Topic: Defect Report: [basic.stc] contradicts [class.temporary] concerning
Author: ljestrada@hotmail.com (Javier Estrada)
Date: Fri, 26 Jul 2002 15:49:10 GMT Raw View
James,
This is the original code that I was trying in my program in VC7
(telephony):
void Provider::handleCallStateIdle(Call *pca, const tapi_call_state&
cs)
{
// Destructor for SingleCallMetaEvent called BEFORE
// call to handleCallState()
SingleCallMetaEvent(pca, IEvent::CAUSE_NORMAL);
pca->handleCallState(cs);
}
But as mentioned in the original post, I saw the destructor being
called before the call to pca->handleCallState().
void Provider::handleCallStateIdle(Call *pca, const tapi_call_state&
cs)
{
// Destructor for SingleCallMetaEvent called AFTER
// call to handleCallState()
SingleCallMetaEvent e(pca, IEvent::CAUSE_NORMAL);
pca->handleCallState(cs);
}
Regards,
Javier
---
[ 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: Hyman Rosen <hyrosen@mail.com>
Date: Sat, 27 Jul 2002 17:51:26 GMT Raw View
Javier Estrada wrote:
> SingleCallMetaEvent(pca, IEvent::CAUSE_NORMAL);
This creates a temporary whose lifetime ends at the end of the
full expression. It is destructed immediately after it is created.
> SingleCallMetaEvent e(pca, IEvent::CAUSE_NORMAL);
This creates an automatic variable whose lifetime ends at the
end of the block in which it is defined. It will be destructed
when the block is exited.
---
[ 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: kanze@gabi-soft.de (James Kanze)
Date: 24 Jul 2002 16:50:18 GMT Raw View
[moderator's note: forwarded to C++ Commitee. -sdc]
There are several problems with 3.7 [basic.stc]:
- [basic.stc]/2 says that "Static and automatic storage durations are
associated with objects introduced by declarations (3.1) and
implicitly created by the implementation (12.2)."
In fact, objects "implicitly created by the implementation" are the
temporaries described in (12.2), and have neither static nor
automatic storage duration, but a totally different duration,
described in 12.2.
- [basic.stc] uses the expression "local object" in several places,
without ever defining it. Presumably, what is meant is "an object
declared at block scope", but this should be said explicitly.
In a recent discussion in comp.lang.c++.moderated, on poster interpreted
"local objects" as including temporaries. This would require them to
live until the end of the block in which they are created, which
contradicts 12.2. If temporaries are covered by this section, and the
statement in [basic.stc]/2 seems to suggest, and they aren't local
objects, then the must have static storage duration, which isn't right
either.
I propose adding a fourth storage duration to the list after
[basic.stc]/1:
-- temporary storage duration
And rewriting the second paragraph of this section as follows:
Temporary storage duration is associated with objects implicitly
created by the implementation, and is described in 12.2
[class.temporary]. Static and automatic storage durations are
associated with objects defined by declarations; in the following,
an object defined by a declaration with block scope is a local
object. The dynamic storage duration is associated with objects
created by the operator new.
--
James Kanze mailto:jkanze@caicheuvreux.com
Conseils en informatique orient e objet/
Beratung in objektorientierter Datenverarbeitung
[ 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 ]