Phred Phungus said:
The whole thing. The following is a constraint: "thou shalt not
divide by zero."
Regarding the above constraint, thou shalt keep it.
Constraints are requirements in the standard in paragraphs explicitly
marked "Constraints".
For example, C99 6.5.2.4 says:
6.5.2.4 Postfix increment and decrement operators
Constraints
1 The operand of the postfix increment or decrement operator shall
have qualified or unqualified real or pointer type and shall
be a modifiable lvalue.
Like most constraints, it expresses the requirement using the word
"shall". The expression ``42'' is not a modifiable lvalue. So if you
write:
42 ++;
you've just violated the constraint, and the compiler is required to
issue a diagnostic message.
On the other hand, C99 6.5.6p9 says:
When two pointers are subtracted, both shall point to elements of
the same array object, or one past the last element of the array
object; the result is the difference of the subscripts of the two
array elements.
Again, the requirement is stated using the word "shall", but it's in
the Semantics subsection, not the Constraints subsection. If you write:
int x;
int y;
ptrdiff_t diff = &x - &y;
you've violated the requirement' but you haven't violated a
constraint. (Rationale: compiler cannot in general detect this
particular error, so it can't reasonably be expected to diagnose
it.) This is where J.2 kicks in (actually section 4 paragraph 2).
Your program's behavior is undefined.
Doesn't the whole thing seem like Ganto's ax (damned if you do/don't)?
Not at all. If you violate such a requirement, your program's
behavior is undefined (and the compiler isn't required to diagnose
the error). If you don't, it isn't.
The "shall" vs. "shall not" just covers two different ways of
expressing a requirement.
There is no mention of the fortran keyword in gcc.pdf.
So there's your answer.
I think the
gcc-gfortran projects are so joined at the hip that they get this
behavior out of the filetypes of the source.
The "fortran" keyword is just one possible mechanism for interfacing
between C and Fortran. As far as I know, it hasn't been widely used
in a very long time.