J3/04-332
Date: 2 Jun 2004
To: J3
From: Richard Maine
Subject: Finalization of structure constructors in specifications
NUMBER:
TITLE: Finalization of structure constructors in specifications
KEYWORDS: finalization, structure constructor, specification expression
DEFECT TYPE:
STATUS: J3 consideration in progress
QUESTION: Paragraphs 3-5 of subclause 4.5.5.2 specify when
finalization occurs for function results in executable constructs
and in specification expressions. They also specify specify
when finalization occurs for structure constructors in executable
constructs. However, structure constructors in specification
expressions do not appear to be mentioned. The apparent
conclusion would be that structure constructors in specification
expressions are not finalized, which seems inconsistent and
contrary to the purpose of finalization.
Q1. Are structure constructors in specification expressions
finalized? If so, when?
The phrase "before the first executable statement in a scoping
unit" is used in two places in the standard (4.5.5.2 and at
[116:8] after note 6.24) to describe the first thing executed in a
scoping unit. This phrase has two problems.
First, not all executable statements can be executed
as single statements; the description of execution sequence is
in terms of executable constructs rather than executable
statements. (See 2.3.4, 8.1.1.3, and 12.5.2.0). Although
this distinction seems unlikely to lead to confusion, the
terminology seems inconsistent.
Second, and more problematic, is that the first executable
statement or construct in a scoping unit is not necessarily the
first thing executed in the scoping unit; nor is it necessarily
executed only once. An entry statement may cause execution to
start at some other executable construct, in which case one might
wonder whether the specified actions ever happen. A goto might
cause the construct to be executed multiple times, in which case
one might wonder whether the specified actions happen again. I
seriously doubt that either of these represent the intent.
Q2. If an event is specified to occcur before the first executable
statement in a scoping unit, then for a single execution of that
scoping unit, may the event happen zero times, multiple times, or
after the execution of some other executable statement or
construct in the scoping unit?
{Side note to J3: Although Q2 picks nits about what I consider to
be technically imprecise wording, I don't really expect anyone to
get it wrong. I wouldn't have bothered to write it up as an
interp question except that I wanted to make the wording of my
edit for Q1 parallel to existing wording, which I then noticed was
odd. Feel free to delete Q2 and its associated material,
pretending that I never put it in the interp if you don't feel it
worth bothering with. Q1 is of a little more concern in that some
implementation might plausibly overlook the same case that the
standard appeared to.}
ANSWER:
A1. Yes, structure constructors in specification expressions are
finalized. Just as with function results in specification
expressions, this finalization occurs before execution of the
executable constructs in the scoping unit. This was an accidental
omission from the standard. Edits are supplied to correct it.
A2. No. The intent is to describe events that happen once and only
once per execution of a procedure defined by a scoping unit.
Edits are supplied to state this more precisely.
EDITS:
[59:30] and [116:8] Change
"first executable statement" -> "executable constructs"
{Side note to J3: I found it simpler to use " the executable
constructs" as a collective whole instead of using enough words to
specify the particular construct and that it is only the first
execution of that construct.}
[59:30+] Insert new para
"If a specification expression in a scoping unit references a
structure constructor, the entity created by the structure
constructor is finalized before execution of the executable
constructs in the scoping unit."
SUBMITTED BY: Richard Maine
HISTORY: 04-332 m169 Submitted