From Newsgroup: comp.lang.c
James Kuyper <
jameskuyper@alumni.caltech.edu> writes:
On 2025-11-01 17:39, Tristan Wibberley wrote:
Follow-up set comp.lang.c
On 01/11/2025 02:45, Richard Damon wrote:
.. [stuff I think is about the invalidity of not completing
execution] isn't a valid definition ...
Let's suppose C disallows abort due to external events... Then no
conforming C implementation exists.
I think we must suppose that susceptibility to power-cuts do not
render C implementations non-conforming.
Correct. What a power cut does is make a conforming implementation
of C fail to continue qualifying as a implementation.
In 1.6 of C89, an implementation is defined as "a particular set of
software, running in a particular translation environment under
particular control options, that performs translation of programs
for, and supports execution of functions in, a particular execution environment."
Thus, when the power is cut, the software ceases to run, so it
ceases to be an implementation, and in particular, ceases to be a
conforming implementation.
The description above is wrong. The C standard clearly shows
that (a) program execution is carried about by a data-processing
system, about which the C standard does not impose any conditions
or requirements, and (b) that implementations are separate and
distinct from the data-processing system(s) in which programs
run. Implementations /support/ execution of functions (and
programs) in an execution environment, but implementations do not
/carry out/ the execution of functions and programs in such an
environment. Execution is carried out by the data-processing
system used to run programs.
The points above may be found in section 1, paragraph 2.
There's important wording that wasn't added to the standard until
C99 that clarified something that was already considered to be true:
"A program that is correct in all other aspects, operating on
correct data, containing unspecified behavior shall be a correct
program and act in accordance with 5.1.2.3." (4p3). The peculiar
wording is intended to make clear that unspecified behavior does not
relieve an implementation of this requirement.
Section 5.1.2.3 indirectly references most of the rest of the
standard, while defining that only the observable behavior of a
program has to match what the standard says - that behavior doesn't
have to be generated in the fashion that the standard describes.
Section 5.1.2.3 in C99 corresponds to 2.1.2.3 in C89.
The rest of the standard defines, among other things, how a program
exits. If the behavior of the program is not undefined, it can only
exit by reaching the end of the main() function, or by calling
certain library functions. If there is any observable behavior that
allows you determine that it ended by any other method, the
implementation is non-conforming.
The comments above reflect a misunderstanding of what is meant by
the word "behavior". In the C standard, "behavior" refers to an
abstract description of program semantics, not what actually
occurs when a program is run by a data-processing system. This
distinction is made evident in section 5.1.2.3 paragraph 1, which
says "The semantic descriptions in this International Standard
describe the behavior of an abstract machine in which issues of
optimization are irrelevant." If when we run a program it runs
out of memory and crashes, that doesn't suddenly make the compiler non-conforming; it could mean just that some other programs are
running and at the moment there is not enough memory available.
The C standard specifically does not concern itself with such
circumstances; see section 1, paragraph 2, the last two marked
sub-paragraphs.
The idea that what happens during program execution can change
whether an implementation is conforming would mean that there are
/no/ conforming implementations, because it's possible to write a
strictly conforming program that will exceed the capacity of any
machine in existence (and indeed, that will exceed the capacity
of any machine that ever will be in existence). Surely the C
standard does not mean to rule out the possibility of any
conforming implementations at all.
--- Synchronet 3.21a-Linux NewsLink 1.2