This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: PATCH: `__norestrict' type qualifier


> > Suppose the only guarantee made about "char *" is that you can use
> > it to copy objects one unit at a time.  (The "unrestricted aliasing"
> > property follows from this guarantee.)  Do you instead want to say
> > that ANY pointer type can be used to copy objects, if you first
> > declare the pointer `norestrict'?  This is unlikely to be acceptable
> > to the standards people.
> 
> Why?  That definition seems concise, reasonable, and useful.
> Just make the "char*" extension apply to "norestrict" also.

ANY pointer is certainly not what you want. If it was "well-formed" to
derefence ANY __norestrict pointer, you would have to allow for
unaligned pointers, as in

int main()
{
  char s[]="Hello, world\n";
  int * __norestrict ip = s+1;
  int i = *ip; // Bus error
}

If that was legal, you'd lose the speed advantage of derefencing int*.
In ISO C, it works for char*, because that one has no alignment
requirements.

Regards,
Martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]