Topic: Defect Report: Section 3.8 looks confusing about object's lifetime
Author: k_satoda@f2.dion.ne.jp (Kazutoshi Satoda)
Date: Sat, 3 Nov 2007 16:53:56 GMT Raw View
[Preface:
I have got worried about class non-static member access in its
constructor. Reading the latest working draft n2369, the issue is not
cleared. It is prohibited (as an undefined behavior) in 3.8 while it is
allowed (with detailed definition) in 12.6 and 12.7.
Looking for the same issue in archives, I found some old posts which
point exact the issue, at 1997 (http://tinyurl.com/2zgb3n), at 2002
(http://tinyurl.com/yuyp97). Please search the archives with "3.8 12.7"
to find more. But none of them seems to be treated as a defect. Now I
tried to make a defect report about the issue.
- end preface]
Accessing to non-static members from its constructor are explicitly
defined in 12.6 and 12.7. But 3.8 can be read to be prohibiting them
as undefined behavior.
Reading the section 3.8, it looks confusing the time object's lifetime
starts (ends) and the time object's construction starts (destruction
completes) which are the same time if the type of the object is a
trivial type.
Let's think a life of an object of non-trivial class type as following.
--1-2--3----4--5-6--
1. The storage is allocated.
2. The constructor starts.
3. The constructor completes.
4. The destructor starts.
5. The destructor completes.
6. The storage is deallocated.
Current standard defines the object's lifetime as 3~4.
Many restrictions described in 3.8 are read to be applied to 1~3 and
4~6. But almost all of the restrictions seems to be intended to be
applied only to 1~2 and 5~6. Forward reference from 3.8p3 to 12.6 and
12.7 which describe about 2~3 and 4~5 implies such intention. Otherwise,
many contradictions arise between them.
--
k_satoda
---
[ 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 ]