J
jaysome
The definition changed between C90 and C99 (and again between C99 and
N1124).
C90 3.10:
implementation-defined behavior: Behavior. for a correct program
construct and correct data, that depends on the characteristics of
the implementation and that each implementation shall document.
C90 3.17:
unspecified behavior: Behavior, for a correct program construct
and correct data, for which this International Standard explicitly
imposes no requirements.
C99 3.4.1:
implementation-defined behavior
unspecified behavior where each implementation documents how the
choice is made
EXAMPLE An example of implementation-defined behavior is the
propagation of the high-order bit when a signed integer is
shifted right.
C99 3.4.4:
unspecified behavior
behavior where this International Standard provides two or more
possibilities and imposes no further requirements on which is
chosen in any instance
EXAMPLE An example of unspecified behavior is the order in which
the arguments to a function are evaluated.
(The definition of "unspecified behavior" was tweaked slightly in
N1124; the revised definition is "use of an unspecified value, or
other behavior where ...".)
C99 5.1.2.2.1 allows main() to be defined in either of the traditional
ways "or in some other implementation-defined manner". But this
doesn't use the term "implementation-defined behavior", which is
defined in section 3. The standard doesn't provide a definition of
"implementation-defined" other than in the context of
"implementation-defined behavior" or "implementation-defined value",
so I think we just have to read it as ordinary English text; "some
other implementation-defined manner" simply means "some other manner
which is defined (i.e., documented) by the implementation". For
implementation-defined *behavior*, the standard must provide two or
more possibilities; for implementation-defined anything-else, it
needn't do so.
Which is exactly what "conforming" means.
A *conforming program* is one that is acceptable to a conforming
implementation.
If I wrote a conforming implementation that allows
struct {char c; long double x;}main(void) {}
then that would become a conforming program. (The concept of a
"conforming program" isn't all that useful.)
I think a conforming program may be more useful than you think. Your
example of a conforming main() might not be so useful, but other
aspects of a conforming program can definitely be useful. That's what
the C Standard allows.
I prefer a conforming implementation to a non-conforming one. And if
my conforming implementation tells me through documentation that I
need to define main() as:
struct {char c; long double x;}main(void) {}
and that I need to set c to my favorite character and set x to the
average price of a pound of baloney in the Salt Lake City region on
the third day of the month, averaged over the past year, then, by God,
I'll do that to get my ZOG 32-bit DSP--where sizeof(char) ==
sizeof(long)--working and appease my boss and collect a well-deserved
paycheck. And I'll have the added comfort knowing that I am
programming in Standard C.