Florian Weimer wrote:

If this still doesn't convince you, here's an example which doesn't
use Ada.Unchecked_Conversion at all.

this example must print Success, that is guaranteed by the RM

it is definitely critical that 'Valid not make "in-range"
assumptions. the actual problem is optimization of this
routine presumably:

      function bug3_p__tRP (A : bug3_p__t; F : boolean) return integer is
      begin
         case system__unsigned_types__unsigned!(A) is
            when 2 =>
               return 0;
            when 3 =>
               return 1;
            when 5 =>
               return 2;
            when 7 =>
               return 3;
            when others =>
               [constraint_error when F "invalid data"]
               return -1;
         end case;
      end bug3_p__tRP;

the unchecked conversion to unsigned must prevent any optimization.
the optimizer must not be able to "see through" an unchecked conversion!


Reply via email to