A
Alf P. Steinbach
* Keith H Duggar:
As already discussed, the standard doesn't use that term "part of the program"
except for denoting a region of text, which wrt. this issue is irrelevant.
§2/1, §2/2 and §2.1 (complete section) are the relevant parts for what
constitutes a program.
§1.4/6 explains what §2.1 is about, ...
"combining translation units to form a complete C++ program (2.1)"
.... so that's what a complete C++ program is, created by /combining translation
units/ according to §2.1.
AFAIK the standard doesn't talk about any lesser unit anywhere.
So the very clear §3.7.1/2 (about how static lifetime objects with side-effect
in initialization or destrution cannot be eliminated) is either talking about
static lifetime objects in the translation units that are combined to form the
program according to §2.1, or it's meaningless, trying to trick us by hinging
the text on a weasel phrase. Which is likely? I think not the latter.
§3.7.1/2
"If an object of static storage duration has initialization or a
destructor with side effects, it shall not be eliminated even if
it appears to be unused, except that a class object or its copy
may be eliminated as specified in 12.8".
By the way, considering your q. I'm revising my view of this for the second
time. I now think Pete was wrong to focus so strongly on the phrase "library
component" in §2.1/1-9 and interpret "library component" as a part of the
translated program text -- if he did. I now think the key word in paragraph 9
is *external*, and considering that paragraph 8 has already combined the
translation units (at least that's a possible and consistent interpretation of
"are combined as follows"), what's left in paragraph 9 is things /external to
the program/ that has now been formed by combining translation units, e.g.
references to functions in the runtime library and operating system API.
I think it's good to have this hashed out in detail.
Even it it should turn out that my new view of paragraph 9 is wrongo...
Cheers & hth.,
- Alf
Eh, I'm not sure I would call such schemes "esoteric". Function
level linking and other smart linking techniques are valuable
optimization tools. I've /wished/ that gnu supported this out
of the box.
Utility aside, what in the standard /guarantees/ that all static
objects in a TU are "part of the program" if /any/ symbol in that
TU is referenced?
As already discussed, the standard doesn't use that term "part of the program"
except for denoting a region of text, which wrt. this issue is irrelevant.
§2/1, §2/2 and §2.1 (complete section) are the relevant parts for what
constitutes a program.
§1.4/6 explains what §2.1 is about, ...
"combining translation units to form a complete C++ program (2.1)"
.... so that's what a complete C++ program is, created by /combining translation
units/ according to §2.1.
AFAIK the standard doesn't talk about any lesser unit anywhere.
So the very clear §3.7.1/2 (about how static lifetime objects with side-effect
in initialization or destrution cannot be eliminated) is either talking about
static lifetime objects in the translation units that are combined to form the
program according to §2.1, or it's meaningless, trying to trick us by hinging
the text on a weasel phrase. Which is likely? I think not the latter.
I certainly believe that the transitive closure of symbols is
part of the program, but all them? Just because they happen to
be in the same TU? Where is this guarantee?
§3.7.1/2
"If an object of static storage duration has initialization or a
destructor with side effects, it shall not be eliminated even if
it appears to be unused, except that a class object or its copy
may be eliminated as specified in 12.8".
By the way, considering your q. I'm revising my view of this for the second
time. I now think Pete was wrong to focus so strongly on the phrase "library
component" in §2.1/1-9 and interpret "library component" as a part of the
translated program text -- if he did. I now think the key word in paragraph 9
is *external*, and considering that paragraph 8 has already combined the
translation units (at least that's a possible and consistent interpretation of
"are combined as follows"), what's left in paragraph 9 is things /external to
the program/ that has now been formed by combining translation units, e.g.
references to functions in the runtime library and operating system API.
I think it's good to have this hashed out in detail.
Even it it should turn out that my new view of paragraph 9 is wrongo...
Cheers & hth.,
- Alf