jejones@mcrware.UUCP (James Jones) (06/08/90)
A little motivational material, though not the only situation in which the question might come up: Suppose a compiler writer intended to support an 80x86 architecture sort of in the "spirit of ANSI C" by providing an additional qualifier, say "far" (or _far to avoid name clashes). This qualifier would presumably act like other qualifiers, but a far-qualified pointer would be one of those segment:offset beasts, and a far-qualified object would be accessed via an explicit segment:offset. The question is: do the ANSI rules for qualifiers let this putative compiler writer do what he wants? It seems to me that the answer is no. To pull the trick off, it has to always be possible to determine the size and semantics of an object. The example for which I think I can quote chapter and verse to show that this wouldn't always be possible is ?:, given the constraint on the second and third operands "both operands are pointers to qualified or unqualified versions of compatible types," i.e. (in notation reminiscent of a previous post--and thanks to those who pointed out my mistake therein!) there are compatible types T1 and T2 such that the second and third operands have types T1 <optional qualifiers> * and T2 <optional qualifiers> * respectively. Now, if T1 = T2 = T *, in particular, one could then have T ** and T * _far * so that the result of the ?: is a pointer to something that might be far-qualified, and might not, so that code wouldn't know what to do after dereferencing the result. Would this be the only case in which one couldn't tell what to do with a pointer? (For that matter, have I misread the constraints?) James Jones