This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH to implement `restrict' in C
- To: egcs at cygnus dot com
- Subject: Re: PATCH to implement `restrict' in C
- From: Jan Hubicka <hubicka at horac dot ta dot jcu dot cz>
- Date: Thu, 15 Oct 1998 20:38:09 +0200
- References: <28987.908089172@hurl.cygnus.com> <199810110812.BAA28063@smtp.earthlink.net> <3621C047.56A6@acm.org>
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