#pragma

Doug Gwyn gwyn at brl-smoke.ARPA
Fri May 27 04:30:18 AEST 1988


In article <1988May25.212239.1724 at utzoo.uucp> henry at utzoo.uucp (Henry Spencer) writes:
>> I explained how you need to understand #pragma...
>You did?  Sorry, Doug, I missed that one.  Perhaps you would repeat it --

The basic argument is that the #pragma wording is only a portion of the
total specification and must not be taken in isolation.  Because a
conforming implementation must meet EVERY portion of the specification,
its interpretation of "implementation-defined" in the #pragma wording
must be constrained by the rest of the Standard, which definitely
specifies that aliasing is allowed.

The key question is obviously, just how much license is granted by the
phrase "implementation-defined".  There are only a couple of analogous
situations in the rest of the proposed Standard, e.g. in 4.9.4.1 it
says "If the file is open, the behavior of the `remove' function is
implementation-defined."  I don't think that was meant to allow an
implementation to start running Conway's game of Life, etc.  Note that
the official definition of "implementation-defined behavior" in 1.6
emphasizes that correct (albeit not strictly conforming) programs CAN
rely on implementation-defined behavior, so it is obviously not intended
to mean that literally "anything goes".

In an ideal programming language designed from scratch, there would be
far fewer "implementation-defined" areas.  Unfortunately a practical C
standard has to depend on such loopholes quite a lot.

>If #pragma is too subtle for mere mortals to understand its implications,
>then it's quite irrelevant whether the truth really is buried there
>somewhere, because mere mortals are the ones implementing the compilers.

I think a request that this be clarified would be quite in order.
Probably we should not lean so heavily on "implementation-defined",
and since the problem seems to occur mainly for #pragma, 3.8.6 is the
best place to address it.  At least a footnote would seem to be useful.

Personally I want #pragma out of the standard, but that seems
unlikely to happen.



More information about the Comp.lang.c mailing list