On Fri, 2009-07-24 at 12:03 -0400, Robert Dewar wrote: > Indeed an alternative approach to handling this problem in GCC would > be to adapt the Ada model for C and C++ which would not be too hard > to do I suspect. Then gcc could be improved to handle this model > better and more effectively with respect to optimization, and both > C/C++ and Ada would benefit.
IIRC the Ada rules allows to raise Constraint_Error earlier rather than later which is interesting for check removal in loops for very common patterns: for I in T'First .. Dynamic_N loop T (I) := 0.0; -- generate check I in T'First .. T'Last end loop; => if Dynamic_N >= T'First and Dynamic_N > T'Last then raise Constraint_Error; end if; for I in T'First .. Dynamic_N loop T (I) := 0.0; -- no generated check end loop; But I might be wrong in my recollection (and I don't think GNAT takes advantage of that), Robert? I also don't know if there's a generic (shared by languages) infrastructure to support this kind of optimization in GCC. Laurent