comp.lang.ada
 help / color / mirror / Atom feed
From: Joseph Wisniewski <wisniewski.ru@gmail.com>
Subject: optimization away of checks in 'valid
Date: Tue, 25 Sep 2012 18:33:54 -0700 (PDT)
Date: 2012-09-25T18:33:54-07:00	[thread overview]
Message-ID: <5a0711d8-81ad-4200-9b6e-a80feffd5302@googlegroups.com> (raw)

Ran into an issue with one compiler having to do with the implementation of 'valid. Was looking for comments as to how other compilers handle this. 

Basically, the question is, if 'valid is called on an integer object, are there conditions under which some of the checks done by 'valid (range checking on an object of an integer subtype) are removed?

Specifically, we had a case where C++ code was not checking the bounds of a integer subtype as it was passed to Ada code via a function parameter. The Ada code _was_ checking via 'valid. 'valid returned true even though the integer value was out of bounds. Turns out the compiler relied on the "allowed assumption" that all callers "check their bounds" for such data. As such, the range checks in 'valid were eliminated as redundant as part of building with optimization on. In fact, I believe the checks were eliminated under no-opt also. 

My question is whether this is similar behavior across compilers or if 'valid is viewed as always performing the same checks, including and perhaps especiallyh bounds checks in this kind of situation.



             reply	other threads:[~2012-09-26  1:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-26  1:33 Joseph Wisniewski [this message]
2012-09-26  8:35 ` optimization away of checks in 'valid Ludovic Brenta
2012-09-26 16:46   ` Jeffrey Carter
2012-09-26 12:01 ` Georg Bauhaus
2012-09-27  6:00 ` Stephen Leake
replies disabled

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