On Friday, April 5, 2019 at 11:56:44 AM UTC-4, Alf P. Steinbach wrote:
> On 05.04.2019 14:46, James Kuyper wrote:
> > On 4/4/19 11:51 PM, Alf P. Steinbach wrote:
> >> On 04.04.2019 14:13, James Kuyper wrote:
> >>> On 4/4/19 6:44 AM, Ben Bacarisse wrote:
> >>>> "Alf P. Steinbach" <
alf.p.stein...@gmail.com> writes:
> >>>>
> >>>>> On 03.04.2019 17:10,
james...@alumni.caltech.edu wrote:
> >>>>>>
> >>>>>> More realistically, an implementation is allowed to, for example, look
> >>>>>> at the expressions array[0][i] and array[1][j], and assume that neither
> >>>>>> expression will be evaluated in a context where i and j have values that
> >>>>>> are out of range, and that it is therefore unnecessary to consider the
> >>>>>> possibility that they alias the same location. Since the behavior would
> >>>>>> be undefined in those cases, ignoring that possibility would not rende
> >>>>>> the implementation non-conforming.
> >>>>>
> >>>>> Thanks, now it appears to be clear where the nonsense comes from,
> >>>>> namely the "optimization" in the GCC compiler.
> >>>>
> >>>> That's unlikely. The wording in the C standard predates gcc.
> >>
> >> The last line above assumes the interpretation that it seeks to prove.
> >
> > How? In the last line, he's attempting to prove that it's unlikely that
> > gcc influenced the committee's decision.
>
> Well, keep in mind that we were talking about two opposing
> interpretations of a piece of the standard, not that wording itself.
>
> The circular assumption is that the committee's intent, what it tried to
> express, was the favored interpretation.
He made no use of that assumption in the line you identified as
containing a circular argument. Regardless of what the committee's
intent was, if gcc did not exist at the time (which is the false
assumption he did make), then gcc could not have possibly influenced the
committee's decision on the matter. While gcc did exist, it was very
young at that time, so it would still be unlikely to have much influence
on the committee's decision. Again, that is true, regardless of what the
committee's actual intent was.
> Without that circular assumption the above would express in a
> Spock-incompatible way that GCC folks could not have made an
> interpretation of wording that already existed, which is a much worse
> fallacy.
I agree that it would be Spock-incompatible, but only because I can't
figure out any way to produce that conclusion from his argument, with or
without the circular assumption you incorrectly claim he relied upon.
If, as he incorrectly assumed, gcc did not exist yet, how could the gcc
folks have possibly formed any interpretation at all, of anything?
That's completely independent of what the committee's intent was.
Since gcc did actually exist in 1989 when those words were first
published, they could in fact interpret those words - but because it was
still in it's infancy at that time, gcc was unlikely to have influenced
how those words were written. Even in 1992 when the committee resolved
DR#017, gcc was still so new that it was unlikely to have significantly
influenced the committee's resolution.
> You showed me, I can't speak for others really though I think they'd
> have stated it if they'd known, that some time after C Defect Report 17
> the committee ruled on what the wording should mean, and decided that it
To be specific, the committee made that ruling when it resolved DR017.
You seem to be assuming that the committee used that ruling to change
their mind about what their wording meant. I don't have any details
about their deliberations on the matter, so I can't be sure, but it's at
least as likely that they merely used that ruling to confirm that the
wording had always been meant to be interpreted in that fashion,
particularly since it seems quite clear to me that this was in fact the
meaning of that wording. Note that the resolution of that DR did not
specify any changes to the wording.
> meant that interpretation, that I had been sure was nonsense on grounds
> of practicality. That resolution is definitive for me. If the above had
> referred to the DR's resolution then it would have been roughly valid,
> since presumably that resolution is known to compiler writers
We're talking about the possibility that gcc influenced the way the
words were originally written, or perhaps the decision that was made
when resolving the defect report (it's your claim that they had such
influence, but I'm not clear from your wording which of those two
possibilities you were thinking of). Any such influence, in order to be
effective, would have had to have occurred, at the very latest, before
the resolution of the DR. Therefore, whether or not gcc folk ever read
the resolution is completely irrelevant to that possibility.
> > I don't
> > see any circularity there. He was incorrect about that point, but only
> > by a couple of years; and it is indeed unlikely that the newly released
> > compiler was already sufficiently influential to control the committee's
> > decisions. It's not impossible, as it would have been if he'd been
> > right, but it's still implausible.
>
> Again, keep in mind that we were talking about two opposing
> interpretations of a piece of the standard, not that wording itself.
We're also talking which of those interpretations is consistent with the
wording. I've seen many explanations of the other interpretation, but
I've never seen an explanation that was consistent with the actual
words.
The key point is that, given
int a[4][5];
The array a has only 4 elements, of the type int[5]. The array a[1] has
only 5 elements, of type int. The expression a[1][7] is equivalent to
*(*(a+1)+7).
Applying the wording in n4762.pdf:
"If the expression P points to element x[i] of an array object x with n
elements, the expressions P + J and J + P (where J has the value j)
point to the (possibly-hypothetical) element x[i + j] if
0 <= i + j <= n; otherwise, the behavior is undefined."
The relevant expression is *(a+1)+7, for which P is "*(a+1)", J is "7",
x is a[1], i is 0, n is 5, and j is 7, thereby violating the requirement
for defined behavior.
Can you identify what P, J, x, i, n, and j are for an interpretation of
these words that does not violate that requirement? A popular choice is
to interpret x as referring to "a". The problem is that P does not
point at any element of a itself, it points into a[1], but it points at
a[1][0], which is an element of a[1], but not an element of a itself.
If you think "point at" could be interpreted as including "point into",
then i=1, and x[i+j] would be a[8], which does not match anyone's claims
for the location that this expression points at, and would violate the
relevant requirement just as badly.
What you'd really have to do is justify identifying *(int(*)[20])a as
the array that you're referring to (I've seen people give arguments
equivalent to that approach) - but the standard doesn't define the
behavior of that expression.
...
> > 2. The particular clauses from the C standard that the C committee used
> > as a basis for it's decision on DR017 were copied into the C++ standard
> > with modifications, rather than being incorporated by reference.
> >
> > This is not particularly unusual - the only significant part of the C
> > standard that was incorporated into the C++ standard by reference was
> > the description of the C standard library. Section 1.7, "Normative
> > references", includes references to the C99 standard and to the next
> > three Technical Corrigenda to that standard, but referring to a standard
> > does not mean incorporating it by reference.
>
> I was referring to
>
> C++14 17.5.1.5
> [quote]
> Paragraphs labeled “See also:” contain cross-references to the relevant
> portions of this International Standard and the ISO C standard, which is
> incorporated into this International Standard by reference.
> [/quote]
In the latest draft that I have access to, the closest equivalent to
that wording is in section 15.4.1.5, titled "C library".
> It was there from the beginning, but in C++17 the part after the comma
> has been removed.
I hadn't realized that there'd been such a change in the relevant
wording. At work, where I am now, I refer to n4762.pdf, which doesn't
use the phrase "incorporated by reference" anywhere. At home I've got a
copy of an older draft, which uses that phrase in exactly one location.
The newer draft does, however, say, in 15.2p2, that
"The descriptions of many library functions rely on the C standard
library for the semantics of those functions. In some cases, the
signatures specified in this document may be different from the
signatures in the C standard library, and additional overloads may be
declared in this document, but the behavior and the preconditions
(including any preconditions implied by the use of an ISO C restrict
qualifier) are the same unless otherwise stated."
which has essentially the same meaning as the older version, even if it
doesn't use the phrase "incorporated by reference". Does your copy have
comparable wording, somewhere?
> Anyway it was in a non-normative section of the standard.
I'm curious - what renders it non-normative? Notes, examples, and
footnotes are non-normative, and the same is true of any part of the
standard which is explicitly labelled "informative". The rest of the
standard is normative. Which of these cases applies to 17.5.1.5 in your
copy?