comp.lang.ada
 help / color / mirror / Atom feed
From: anon@anon.org (anon)
Subject: Re: Ada checks suppression thanks to compilation options and Ada conformity
Date: Fri, 09 Nov 2007 06:07:41 GMT
Date: 2007-11-09T06:07:41+00:00	[thread overview]
Message-ID: <NOSYi.72026$kj1.8268@bgtnsc04-news.ops.worldnet.att.net> (raw)
In-Reply-To: 4733972C.C7E7BCE@free.fr

Even though your program may or may not be coded to raise a  
CONSTRAINT_ERROR or NUMERIC_ERROR, other functions and packages 
may use them or the hardware may raise them. 

Since the Suppress and Restrictions pragmas are apart of the Ada 
Standards, then they are not a way of getting around Ada norms. Ada 
unlike other languages has a few extra features built-in, which can be 
used for testing and debugging.  So during the development phase a 
programmer may use the normal build-in error checking and exceptions 
while testing a routine and then later add programmer defined validation 
when and as needed. Then once the routine is tested the build-in error 
checking can be removed to save execution time and space. 

Embedded devices such as cell phones or pdas are an example of where 
saving time and space is high on a programmer list. Because most Cell 
phones and PDAs have limited memory and both have slower clock speeds. 
So any time saving and space reducing method must be used in these 
devices.

Plus, in device driver routines the data should be validated before it 
is to and from the data buffer and program. But the transfer between the 
data buffer and the actual device the checking needs to be removed. Or 
these checks may cause either over or under runs for the transfer of data.

Also, once the data is validated at the entry or creation point it does 
not need to be validated at each routine that handles the data unless 
that routine alters the data.

Another example is accessing the co-processors like the FPU.  If the 
FPU does a divide, the only thing that happens is the correct FPU 
status flags are set and the normal FPU interrupt.  Now if the FPU 
does a divide-by-zero the only different is that the divide-by-zero 
status flag is set. It may or may not use the divide-by-zero CPU 
interrupt, but the CONSTRAINT_ERROR usage is software controlled.


--
-- a.adb
--
--
-- Uncomment either or both:
--
-- pragma Suppress ( All_Checks ) ;
-- pragma Restrictions ( No_Exceptions ) ;

with Ada.Text_IO ;

procedure a is

  b : string ( 1..1 ) ;

--  c : integer := 0 ;
--  d : integer := 1 ;
--  e : integer := 2 ;

  c : float := 0.0 ;
  d : float := 1.0 ;
  e : float := 2.0 ;

begin -- a
  Ada.text_io.put_line ( "Assign B" ) ;

  b := "55" ; -- Should cause a Constraint_Error 
              -- either pragma : allow code to continue

  Ada.text_io.put_line ( "Perform Divide by Zero" ) ;

  e := d / c ; -- Should cause a Constraint_Error 
               -- either pragma : allows code to continue for FPU
               --                 float instruction but a core dump 
               --                 may result for CPU integer divide

  Ada.text_io.put_line ( "End of Job" ) ;

end a ;


In <4733972C.C7E7BCE@free.fr>, Christophe TRAVERS <christophe.travers1@free.fr> writes:
>I send this message in order to get your opinion on the following
>subject :
>
>An Ada program was supposed to take into account the Ada exceptions :
>CONSTRAINT_ERROR, NUMERIC_ERROR, ...
>The pragma SUPPRESS was forbidden. So, it was not used in the Ada source
>code.
>Everybody was convinced that the exception mechanism was fully
>operational in the embedded object executable.
>
>Nevertheless,  the object code was compiled thanks to the Ada TARTAN
>compiler with some compilation options  have suppressed all the "checks"
>in the entire object code.
>
>From my point of view, these compilation options that can suppress the
>checks are a way to get around the Ada language norm.
>
>What it you opinion on this suject?.
>
>Sincerely.
>
>
>
>
>
>




  parent reply	other threads:[~2007-11-09  6:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-08 23:09 Ada checks suppression thanks to compilation options and Ada conformity Christophe TRAVERS
2007-11-08 23:52 ` Ludovic Brenta
2007-11-09  0:15 ` Jeffrey Creem
2007-11-09  0:25 ` Adam Beneschan
2007-11-09  6:07 ` anon [this message]
     [not found]   ` <13j8b1pjln94ce@corp.supernews.com>
2007-11-10 20:21     ` Christophe TRAVERS
     [not found] ` <13j8b1oon6rvncd@corp.supernews.com>
2007-11-10 20:54   ` Christophe TRAVERS
2007-11-10 22:00   ` Keith Thompson
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox