Article View: comp.std.c
Article #1411qualifier rules versus pointer layout
From: James Jones
Date: Fri, 08 Jun 1990 16:30
Date: Fri, 08 Jun 1990 16:30
42 lines
2094 bytes
2094 bytes
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
Technical Details
Message-ID:
<1693@mcrware.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcrware!jejonesShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcrware!jejones From: jejones@mcrware.UUCP (James Jones) Newsgroups: comp.std.c Subject: qualifier rules versus pointer layout Keywords: hypothetical type qualifiers, pointers, ?: Message-ID: <1693@mcrware.UUCP> Date: 8 Jun 90 16:30:37 GMT Organization: Microware Systems Corp., Des Moines, Ia. Lines: 42