Newsgroups: comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: no noalias not negligible (long) Message-ID: <1988May23.012636.1719@utzoo.uucp> Organization: U of Toronto Zoology References: <54080@sun.uucp> <11608@mimsy.UUCP>, <7950@brl-smoke.ARPA> Date: Mon, 23 May 88 01:26:36 GMT > ... all the editors of official documents are in > agreement that the proposed Standard does not permit (and certainly > is not intended to permit) #pragma to allow violation of any portion > of the rest of the Standard specifications... This is, of course, yet another example of why most ANSI C compilers will have an option setting with two values: "strict conformance" and "do it right". The fact is that #pragma is the obvious way to declare such additional information about programs, and that's what most compiler writers will use. The alternative of having "__magic_cookie" identifiers is much less satisfactory; with #pragma there is a reasonable chance that the code remains portable (although its efficiency may not). Compilers are required to ignore unrecognized #pragmas (although I for one think a warning message is in order...), but "__magic_cookie" is a different and messier situation. Also, after some study of the 2nd-public-comment draft, I fear I can't support the editors' view. Depending on how one interprets the meaning of various words, one *can* come up with that conclusion -- but it is *NOT* the "interpretation of least astonishment". The description of #pragma just says "causes the implementation to behave in an implemen- tation-defined manner". While this arguably doesn't allow alteration of the semantics of other parts of the program, it seems to me that it does allow the #pragma itself to turn into "abort();" or "printf("foo\n");" or "#include ". This being the case, no strictly-conforming program can contain a #pragma, since this would make its output depend on implementation-defined characteristics. THAT being the case, strange semantics for #pragma are an extension which does not alter the behavior of strictly-conforming programs -- and this sort of extension is explicitly legal for conforming compilers. I can find no hole in the above argument without violating the Law of Least Astonishment... which is the principle that persons other than X3J11 members will necessarily rely on to interpret the standard. If X3J11 wishes #pragma to be constrained not to alter the semantics of the rest of the language, it is going to have to make this explicit. Any such effort should recognize that this restriction will definitely be in the running for "clause most frequently ignored for good reason". -- NASA is to spaceflight as | Henry Spencer @ U of Toronto Zoology the Post Office is to mail. | {ihnp4,decvax,uunet!mnetor}!utzoo!henry