Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Ada > Curiosity about...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 8 Topic 5540 of 5874
Post > Topic >>

Curiosity about rage checking

by "framefritti@[EMAIL PROTECTED] " <framefritti@[EMAIL PROTECTED] > Feb 7, 2008 at 12:17 AM

Dear *,
this morning, while I was shaving myself, a curiosity about array
access checking in Ada came to my mind...

Consider the following piece of code

for I in A..B loop                                         --
<--------------------+
    Put_Line("Assigning entry for I=" & Integer'Image(I));
--                        |
 
--                        |
    X(I) := 0;    --  <== Access checking for this assignement could
be moved  here--+
end loop


As explained in the fancy comment (I hope you are seeing it with a
fixed-size font :-) the check for
index overflow in the access to X could be done _outside_ the for
loop, saving some computational
effort.

My question is: is an Ada compiler allowed to move the check outside
the loop?


Let me raise few objections myself

  1. The saving is not very im****tant
         But it comes for free (it seems to me).  Moreover, the type
of array access used above is (in my
opinion) very common.

  2. Moving the check outside the loop changes the program behaviour
         if, for example, X index ranges from 1 to 5, A=3 and B=6,
with the check inside the loop 3
iterations are done (and 3 lines are printed), while with the check
outside the loop no iteration is
done.  Therefore, the program behaves differently.  However, the
program is buggy anyway, and
maybe we are not so interested in preserving the behaviour of wrong
programs....

 3. It make debugging harder
   This is a good objection since the exception is raised _before_
(and sometimes much before) the
error actually happens.  Maybe one could use usual access checking
during the debug phase, while
keeping "optimized" checking in the production phase.

Thank you 2#10_0000_0000#
 




 8 Posts in Topic:
Curiosity about rage checking
"framefritti@[EMAIL   2008-02-07 00:17:35 
Re: Curiosity about rage checking
Maciej Sobczak <see.my  2008-02-07 00:45:19 
Re: Curiosity about rage checking
Jean-Pierre Rosen <ros  2008-02-07 10:55:24 
Re: Curiosity about rage checking
"framefritti@[EMAIL   2008-02-07 02:36:01 
Re: Curiosity about rage checking
"Dmitry A. Kazakov&q  2008-02-07 12:21:01 
Re: Curiosity about rage checking
Adam Beneschan <adam@[  2008-02-07 07:57:05 
Re: Curiosity about rage checking
Robert A Duff <bobduff  2008-02-07 11:45:46 
Re: Curiosity about rage checking
Adam Beneschan <adam@[  2008-02-07 08:54:56 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Aug 27 17:46:42 CDT 2008.