restrict and pointer casting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

I've been looking around for info about the "restrict" keyword. I have found a document titled:

Restricted Pointers in C
Numerical C Extensions Group, Aliasing Subcommittee
Final Report: Draft 2, X3J11/94-019, WG14/N334

But I'm not sure if this is actually part of the c99 standard. Is this the definitive document?

In section 3.8 it discusses the assignment of a restricted pointer value to a pointer not declared as restricted, and the text reads "If a compiler tracks pointer values, it should be able to optimize the loop as effectively as if the restricted pointers ... were used directly." Presumably, therefore, the propagation of restrict in such cases is implementation dependent. Can we assume GCC versions from 4 onwards will implement this?

Section 3.9 explains that casting a non-restricted pointer to a restricted pointer type does not have any effect. However, it is not clear in this section what the behaviour should be when we cast a restricted pointer to another pointer type (with or without the restrict keyword). Should I read "...the two casts make no assertion about aliasing of the references through the pointers..." to mean the casted pointer has the same restrictedness property as the original pointer? Or that casted pointers are non-restricted in all cases? 

It would appear that the same pointer-value tracking issue might apply here, i.e. that my previous question might be implementation-dependant. 

As a final question, how tractable is the gcc implementation in this area? Are these choices just simple policy code or are they locked into complicated algorithms?

Thanks, John






[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux