+2008-09-08 Daniel Kraft <d@domob.eu>
+
+ PR fortran/37199
+ * trans-expr.c (gfc_add_interface_mapping): Set new_sym->as.
+ (gfc_map_intrinsic_function): Added checks against NULL bounds in
+ array specs.
+
2008-09-08 Tobias Burnus <burnus@net.b.de>
PR fortran/37400
/* Create a new symbol to represent the actual argument. */
new_sym = gfc_new_symbol (sym->name, NULL);
new_sym->ts = sym->ts;
+ new_sym->as = gfc_copy_array_spec (sym->as);
new_sym->attr.referenced = 1;
new_sym->attr.dimension = sym->attr.dimension;
new_sym->attr.pointer = sym->attr.pointer;
/* Convert intrinsic function calls into result expressions. */
+
static bool
-gfc_map_intrinsic_function (gfc_expr *expr, gfc_interface_mapping * mapping)
+gfc_map_intrinsic_function (gfc_expr *expr, gfc_interface_mapping *mapping)
{
gfc_symbol *sym;
gfc_expr *new_expr;
else
arg2 = NULL;
- sym = arg1->symtree->n.sym;
+ sym = arg1->symtree->n.sym;
if (sym->attr.dummy)
return false;
for (; d < dup; d++)
{
gfc_expr *tmp;
+
+ if (!sym->as->upper[d] || !sym->as->lower[d])
+ {
+ gfc_free_expr (new_expr);
+ return false;
+ }
+
tmp = gfc_add (gfc_copy_expr (sym->as->upper[d]), gfc_int_expr (1));
tmp = gfc_subtract (tmp, gfc_copy_expr (sym->as->lower[d]));
if (new_expr)
gcc_unreachable ();
if (expr->value.function.isym->id == GFC_ISYM_LBOUND)
- new_expr = gfc_copy_expr (sym->as->lower[d]);
+ {
+ if (sym->as->lower[d])
+ new_expr = gfc_copy_expr (sym->as->lower[d]);
+ }
else
- new_expr = gfc_copy_expr (sym->as->upper[d]);
+ {
+ if (sym->as->upper[d])
+ new_expr = gfc_copy_expr (sym->as->upper[d]);
+ }
break;
default:
+2008-09-08 Daniel Kraft <d@domob.eu>
+
+ PR fortran/37199
+ * gfortran.dg/array_function_2.f90: New test.
+
2008-09-08 Tobias Burnus <burnus@net.b.de>
PR fortran/37400
--- /dev/null
+! { dg-do run }
+! { dg-options "-fbounds-check" }
+
+! PR fortran/37199
+! We used to produce wrong (segfaulting) code for this one because the
+! temporary array for the function result had wrong bounds.
+
+! Contributed by Gavin Salam <salam@lpthe.jussieu.fr>
+
+program bounds_issue
+ implicit none
+ integer, parameter :: dp = kind(1.0d0)
+ real(dp), pointer :: pdf0(:,:), dpdf(:,:)
+
+ allocate(pdf0(0:282,-6:7))
+ allocate(dpdf(0:282,-6:7)) ! with dpdf(0:283,-6:7) [illegal] error disappears
+ !write(0,*) lbound(dpdf), ubound(dpdf)
+ dpdf = tmp_PConv(pdf0)
+
+contains
+ function tmp_PConv(q_in) result(Pxq)
+ real(dp), intent(in) :: q_in(0:,-6:)
+ real(dp) :: Pxq(0:ubound(q_in,dim=1),-6:7)
+ Pxq = 0d0
+ !write(0,*) lbound(q_in), ubound(q_in)
+ !write(0,*) lbound(Pxq), ubound(Pxq)
+ return
+ end function tmp_PConv
+
+end program bounds_issue