[fortran,patch] Fix PR35685, one more "zero-sized sections gave wrong UBOUND" issue

FX fxcoudert@gmail.com
Mon May 12 21:56:00 GMT 2008


I fixed quite a few last year, and thought I had them all... but  
apparently not so!

Bootstrapped and regtesting on x86_64-linux, comes with a testcase.  
OK to commit?

FX





2008-05-12  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>

         PR fortran/35685
         * trans-intrinsic.c (gfc_conv_intrinsic_bound): Correctly
         handle zero-size sections.


2008-05-12  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>

         PR fortran/35685
         * gfortran.dg/bound_3.f90: New test.

Index: gcc/fortran/trans-intrinsic.c
===================================================================
--- gcc/fortran/trans-intrinsic.c       (revision 135088)
+++ gcc/fortran/trans-intrinsic.c       (working copy)
@@ -938,6 +938,8 @@ gfc_conv_intrinsic_bound (gfc_se * se, g
           size = fold_build2 (MINUS_EXPR, gfc_array_index_type,  
ubound, lbound);
           se->expr = fold_build2 (PLUS_EXPR, gfc_array_index_type,  
size,
                                   gfc_index_one_node);
+         se->expr = fold_build2 (MAX_EXPR, gfc_array_index_type, se- 
 >expr,
+                                 gfc_index_zero_node);
         }
        else
         se->expr = gfc_index_one_node;
Index: gcc/testsuite/gfortran.dg/bound_3.f90
===================================================================
--- gcc/testsuite/gfortran.dg/bound_3.f90       (revision 0)
+++ gcc/testsuite/gfortran.dg/bound_3.f90       (revision 0)
@@ -0,0 +1,20 @@
+! { dg-do run }
+!
+  call s(1,0)
+  call s(2,0)
+  call s(3,0)
+  call s(4,0)
+  call s(5,1)
+  call s(6,2)
+  call s(7,3)
+contains
+  subroutine s(n,m)
+    implicit none
+    integer n, m
+    real x(10)
+    if (any (lbound(x(5:n)) /= 1)) call abort
+    if (lbound(x(5:n),1) /= 1) call abort
+    if (any (ubound(x(5:n)) /= m)) call abort
+    if (ubound(x(5:n),1) /= m) call abort
+  end subroutine
+end program


-- 
François-Xavier Coudert
http://www.homepages.ucl.ac.uk/~uccafco/



More information about the Fortran mailing list