This is the mail archive of the gcc-patches@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: [Ada] Fix problem in convert_with_check


On Sat, 2006-03-04 at 19:30 +0100, Eric Botcazou wrote:
> It's one of the problems uncovered by Jeff with his Ada-killer patch. :-)
> 
> In a few cases, Gigi builds types that are not present in the Ada source.
> convert_with_check was converting the expression to be checked to the Ada
> base type (present in the source) instead of the real base type, which
> can lead to the following GIMPLE code:
> 
>             D.756 = for_the_value /[rd] 1000000000;
>             D.757 = (UNSIGNED_64) D.756;
>             if (D.757 > 255)
>               {
>                 __gnat_rcheck_10 ("c460008.adb", 35);
>                 iftmp.5 = for_the_value /[rd] 1000000000;
>               }
>             else
>               {
>                 iftmp.5 = for_the_value /[rd] 1000000000;
>               }
>             iftmp.6 = iftmp.5;
>             if (0)
>               {
>                 goto <D760>;
>               }
>             else
>               {
>                 
>               }
>             D.763 = (c460008__unsigned_edge_8) iftmp.6;
>             D.764 = (c460008__unsigned_edge_8___UMT) D.763;
>             if (D.764 > 254)
>               {
>                 goto <D760>;
>               }
>             else
>               {
>                 goto <D761>;
>               }
>             <D760>:;
>             __gnat_rcheck_12 ("c460008.adb", 35);
> 
> This is problematic because the expression in the original type iftmp.6
> is converted to the (Ada base) type c460008__unsigned_edge_8 before the
> check in the real type c460008__unsigned_edge_8___UMT that would validate
> the conversion, thus potentially allowing objects of the former type to
> have values outside its TYPE_MIN_VALUE..TYPE_MAX_VALUE range.
> 
> The change fixes ACATS c460008 and c460011 at -O2 so we are left with:
> 
>                 === acats tests ===
> FAIL:   c34004a
> FAIL:   c46033a
> FAIL:   cdd2a02
> FAIL:   cxa4025
> FAIL:   cxa4028
> FAIL:   cxa4033
> FAIL:   cxg2024
> 
>                 === acats Summary ===
> # of expected passes            2309
> # of unexpected failures        7
> 
> of which cdd2a02 should be considered nominal.
> 
> Bootstrapped/regtested on x86, applied to mainline.
> 
> 
> 2006-03-04  Eric Botcazou  <ebotcazou@adacore.com>
> 
> 	* gigi.h (get_ada_base_type): Delete.
>         * utils2.c (get_ada_base_type): Likewise.
>         * trans.c (convert_with_check): Operate in the real base type.
Thanks.  A half-dozen to go....  I know how I'm spending Monday :-)

jeff


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