Subj : Re: Requirements imposed for non-strictly-conforming programs To : comp.programming.threads,comp.std.c From : Chris Croughton Date : Fri Feb 18 2005 10:37 am On Fri, 18 Feb 2005 07:09:21 GMT, David Hopwood wrote: > Here is the [C99] definition of "strictly conforming" (it is a definition > because "strictly conforming" is in italics): > > # A /strictly conforming/ program shall use only those features of the > # language and library specified in this International Standard.2) It > # shall not produce output dependent on any unspecified, undefined, or > # implementation-defined behavior, and shall not exceed any minimum > # implementation limit. > # > # 2) A strictly conforming program can use conditional features (such as > # those in annex F) provided the use is guarded by a #ifdef directive > # with the appropriate macro. [example snipped] > > > This excludes, at least, code with behaviour that is defined to be a > nondeterministic choice of several alternatives (what the C standard > somewhat misleadingly terms "unspecified behaviour"). But clause 4 #3 > then effectively says that the implementation is nevertheless required > to choose one of the alternatives each time such behaviour occurs. > This occurs very frequently in all POSIX multithreaded programs, because > thread scheduling is unspecified. By your interpretation, read strictly, any program which produces behaviour based on an external event (such as the time) is therefore not /strictly conforming/. I don't believe that this is what the spec. means, however, because it talks explicitly about unspecified, undefined and implementation defined behaviours, and thus implies that the program must produce consistent output if the input (including the time etc.) is the same, whereas your interpretation is looking at undefined external inputs (scheduling). > No, there is no definition of what "correct" means. The point, though, > is that whatever "correct" means, this clause imposes requirements on > implementations for code that is not strictly conforming. Indeed, it basically says that if a program is conforming in all aspects except for those dependent on UB/IB then the execution of it must behave in all ways the same except for those dependent on the UB/IB (so the implementation can't say "this is a non-conforming program, I'll completely garble the whole thing"). Chris C (note followups) .