On 2/19/19 10:18 AM, Joseph Myers wrote:
On Tue, 19 Feb 2019, Martin Sebor wrote:

Sure, the text is in a section named Program startup, but that doesn't
imply that the constraints apply only at program startup.  If they did,

I think it's clear from the context that the section is describing the
interface between the program and its environment, not the interface
between a recursive caller of main and the so-called instance of main -
that argc and argv there refer to the specific argc and argv objects for
the initial call of main, not the different objects involved in any
recursive call.  Furthermore, the statement that the parameters can be
modified does not restrict such modifications to preserving the given
properties (normal practice such as ++argv; --argc; would mean that there
are sequence points at which those objects do not have the properties
given).

there would be no constraints on the parameters in any other calls to
main, which would make the parameters unusable in general (because
there is no way for main to tell if it's the fist invocation).

If a program chooses to call main recursively, presumably it has its own
way to tell (e.g. some global variable the call to main can check).

It's an interesting interpretation but I'm having trouble imagining
it's an intended one.  It feels like a (big) stretch to me to say
that if main is careful not to rely on the parameters' constraints
then they need not apply to it.

But since there appear to be two possible ways to read the standard
on this point I think it's worth clarifying.  Not so much to validate
the optimization but simply as a matter of principle.

Martin

Reply via email to