This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PR 23046. Folding predicates involving TYPE_MAX_VALUE/TYPE_MIN_VALUE(Ada RFC)


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!



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]