This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH: `__norestrict' type qualifier
>>>>> "Jamie" == Jamie Lokier <egcs@tantalophile.demon.co.uk> writes:
Jamie> I think I have a suitable (if roughly phrased) definition:
Jamie> Reading an object of type A through a pointer of type
Jamie> `__norestrict B *' shall have the same, implementation-defined
Jamie> behaviour as copying the A into field `a' of a temporary of
Jamie> type `union { A a; B b; }', and then reading field `b'.
Jamie> Writing an object of type A through a pointer of type
Jamie> `__norestrict B *' shall have the same, implementation-defined
Jamie> behaviour as writing to field `b' of a temporary of type
Jamie> `union { A a; B b; }', and then copying field `a' into the A.
Interesting idea; much cleaner than mine.
patl> Yeah, and it might be simplest to just rename it "__typealias",
patl> define its behavior in terms of GCC's aliasing assumptions, and
patl> forget about every trying to standardize it.
Jamie> I think the above definition is equivalent to this, but
Jamie> there's plenty of scope for being wrong :-)
Yes, there is plenty of scope for being wrong, as you have adequately
demonstrated with my earlier proposal.
Here is a question. If I have a `union { short s; long l}', and I
write to the long and read from the short, do I get the same answer as
if I wrote the long to memory, took a pointer to it, cast it to a
short *, and dereferenced that? (I'm not asking about standard C
here, of course; I am asking about GCC's implementation.) If the
answer is "no" for any architecture that GCC supports, then your
definition of __norestrict doesn't meet our needs... Or at least, it
doesn't describe what my patch implements :-).
- Pat