comp.lang.ada
 help / color / mirror / Atom feed
* Test for > 'last
@ 2003-03-14 12:06 Peter Richtmyer
  2003-03-14 12:24 ` Jeffrey Creem
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Peter Richtmyer @ 2003-03-14 12:06 UTC (permalink / raw)


This may be trivial, but I have come across some code
in a (weapon control) system that does checks similar
to:

    ---------------------------------------
    if enum_input < enum_type'first or 
       enum_input > enum_type'last then 
       -- handle the input error
    ---------------------------------------

I have experimented, and found that this type of code
could do at least 3 different things, depending upon 
the compiler and error-checking options:

 - always say that "enum_input" is OK, regardless of its "validity"
 - always raise an exception when the data is invalid
 - work as intended

I think they were running the code with no exceptions
being raised.

I also think the code should be using the 'valid test instead.

But I am wondering whether people think the original code
is OK, sort of wrong, really grossly wrong, or what.

thanks,
Peter



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-03-17 11:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-14 12:06 Test for > 'last Peter Richtmyer
2003-03-14 12:24 ` Jeffrey Creem
2003-03-14 17:22 ` Ant
2003-03-14 18:10   ` Vinzent Hoefler
2003-03-17 11:28     ` Ant
2003-03-15  2:02 ` Jeffrey Carter

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