Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!uunet!algor2.algorists.com!jeffrey From: jeffrey@algor2.algorists.com (Jeffrey Kegler) Newsgroups: comp.std.c Subject: Do non-trivial strictly conforming programs exist? Summary: I don't think so. Keywords: ANSI C strictly conforming Message-ID: <1989Sep8.230612.6629@algor2.algorists.com> Date: 8 Sep 89 23:06:12 GMT Reply-To: jeffrey@algor2.UUCP (Jeffrey Kegler) Organization: Algorists, Inc. Lines: 52 One of the hopes I had for the standard was the ability to write certain programs where portability is guaranteed. I was hoping that making them strictly conforming would do it. Reading the standard has dashed that hope. I honestly hope the following is wrong and that someone can point out how to write non-trivial strictly conforming programs. Section 2.2.4.1 says that "the implementation shall be able to translate and execute at least one program that contains at least one instance of every one of the following limits." This is loosely enough worded to allow a conforming implementation to reject almost any program. This apparently did not escape the Committee, whose Rationale points out "a deficient implementation could probably contrive a program that meets this requirement, yet still succeed in being useless." More of a threat than completely useless conforming implementations are a number of seriously deficient ones, each deficient in a different area. Since a strictly conforming program must be portable to them all, it must embody the lowest common denominator. This can be low indeed. The Rationale expresses the hope that "ingenuity [ in contriving a useless implementation ] would probably require more work than making something useful." In the real world of compiler vendors, examples of implementations going out of their way to be defective are not hard to find. But let's assume the only danger is laziness and stupidity. Take the limit that requires one to allow "31 parameters in one macro definition." Space is at a premium, I want to allow a lot of macros, and I am too lazy or stupid to do anything but reserve the maximum space required for 31 parameters for each macro. My implementation can have a "oversize flag" in the macro table, putting the parameters in a special overflow area if more than one parameter is required. That overflow table need only have room for one macro's parameters for the implementation to be conforming. I will leave it as an exercise to the reader to think of even sicker implementations which conform. There is one group of programs I can find that are strictly conforming. The standard requires a strictly conforming program "not produce output depending on any unspecified, undefined, or implementation-defined behavior, ... ." Any program which produces no output may therefore take advantage of implementation-defined behavior. -- Jeffrey Kegler, Independent UNIX Consultant, Algorists, Inc. jeffrey@algor2.ALGORISTS.COM or uunet!algor2!jeffrey 1762 Wainwright DR, Reston VA 22090