no noalias not negligible (long)

Henry Spencer henry at utzoo.uucp
Mon May 23 11:26:36 AEST 1988


> ... 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 <somethingfunny>".  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



More information about the Comp.lang.c mailing list