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 to implement `restrict' in C


Hi
About week ago I've talked with Pavel about GNU C and he came with quite
interesting idea (probably well known to compiler folks, don't know)

When you are debugging program using asserts, you are writing plenty of
extra informations about various thinks. So quite natural idea is
to turn assert into builtin, wich don't generate any code (when debbuging
is disabled) but passes it to optimizer.
So when you write something like assert(p1!=p2); you can do something like
restrict (actually it has to be something like assert(abs(p1-p2)>sizeof(*p1));)

I believe that it should be possible to make gcc to take advantage of some simple
assertions (like assert(a>0);) and should bring quite clean and natural way
how to write informations to optimizer... Gcc actually does it in conditions,
so makng assertions act like "conditions" should do the job.

Last advantage is that it should force people to write asserts in their code
and improve their programming style and reduce debugging time as well..

I am not sure about implementation issues, but it should be interesting
for gcc hackers..

Honza


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