Executing on host: /test/gnu/gcc/objdir/gcc/testsuite/gfortran/../../gfortran -B /test/gnu/gcc/objdir/gcc/testsuite/gfortran/../../ /test/gnu/gcc/gcc/gcc/testsui te/gfortran.dg/array_constructor_11.f90 -O0 -pedantic-errors -L/test/gnu/gc c/objdir/hppa64-hp-hpux11.11/./libgfortran/.libs -L/test/gnu/gcc/objdir/hppa64-h p-hpux11.11/./libgfortran/.libs -L/test/gnu/gcc/objdir/hppa64-hp-hpux11.11/./lib iberty -lm -o ./array_constructor_11.exe (timeout = 300) PASS: gfortran.dg/array_constructor_11.f90 -O0 (test for excess errors) Setting LD_LIBRARY_PATH to .:/test/gnu/gcc/objdir/hppa64-hp-hpux11.11/./libgfort ran/.libs:/test/gnu/gcc/objdir/hppa64-hp-hpux11.11/./libgfortran/.libs:/test/gnu /gcc/objdir/gcc:.:/test/gnu/gcc/objdir/hppa64-hp-hpux11.11/./libgfortran/.libs:/ test/gnu/gcc/objdir/hppa64-hp-hpux11.11/./libgfortran/.libs:/test/gnu/gcc/objdir /gcc Operating system error: Not a typewriter Out of memory FAIL: gfortran.dg/array_constructor_11.f90 -O0 execution test Simplified test: ! Like array_constructor_6.f90, but check iterators with non-default stride, ! including combinations which lead to zero-length vectors. ! { dg-do run } program main implicit none call build (77) contains subroutine build (order) integer :: order, i, j ! Triggers compile-time iterator calculations in trans-array.c call test (1, 0, 3, (/ (i, i = 1, 0, 3), (i, i = order, 0, 1) /)) end subroutine build subroutine test (from, to, step, values) integer, dimension (:) :: values integer :: from, to, step, last, i last = 0 do i = from, to, step last = last + 1 if (values (last) .ne. i) call abort end do if (size (values, dim = 1) .ne. last) call abort end subroutine test end program main
Operating system error: Not a typewriter Out of memory uhm, this doesn't make too much sense. Can you debug this?
realloc is called with a NULL pointer and 0 size. realloc (0, 0) returns NULL. This causes _gfortran_os_error to get called and the above error to get printed.
My mistake. This comes from a typo in trans.c (a EQ_EXPR instead of an NE_EXPR). Could you test this patch? Index: trans.c =================================================================== --- trans.c (revision 129869) +++ trans.c (working copy) @@ -829,19 +829,19 @@ internal_realloc (void *mem, size_t size { if (size < 0) runtime_error ("Attempt to allocate a negative amount of memory."); - mem = realloc (mem, size); - if (!mem && size != 0) + res = realloc (mem, size); + if (!res && size != 0) _gfortran_os_error ("Out of memory"); if (size == 0) return NULL; - return mem; + return res; } */ tree gfc_call_realloc (stmtblock_t * block, tree mem, tree size) { - tree msg, res, negative, zero, null_result, tmp; + tree msg, res, negative, nonzero, zero, null_result, tmp; tree type = TREE_TYPE (mem); size = gfc_evaluate_now (size, block); @@ -868,10 +868,10 @@ gfc_call_realloc (stmtblock_t * block, t gfc_add_modify_expr (block, res, fold_convert (type, tmp)); null_result = fold_build2 (EQ_EXPR, boolean_type_node, res, build_int_cst (pvoid_type_node, 0)); - zero = fold_build2 (EQ_EXPR, boolean_type_node, size, - build_int_cst (size_type_node, 0)); + nonzero = fold_build2 (NE_EXPR, boolean_type_node, size, + build_int_cst (size_type_node, 0)); null_result = fold_build2 (TRUTH_AND_EXPR, boolean_type_node, null_result, - zero); + nonzero); msg = gfc_build_addr_expr (pchar_type_node, gfc_build_cstring_const ("Out of memory")); tmp = fold_build3 (COND_EXPR, void_type_node, null_result, @@ -881,6 +881,7 @@ gfc_call_realloc (stmtblock_t * block, t /* if (size == 0) then the result is NULL. */ tmp = fold_build2 (MODIFY_EXPR, type, res, build_int_cst (type, 0)); + zero = fold_build1 (TRUTH_NOT_EXPR, boolean_type_node, nonzero); tmp = fold_build3 (COND_EXPR, void_type_node, zero, tmp, build_empty_stmt ()); gfc_add_expr_to_block (block, tmp);
Subject: Re: FAIL: gfortran.dg/array_constructor_11.f90 -O1 execution test > Could you test this patch? Yes, tonight. Thanks. Dave
Subject: Re: FAIL: gfortran.dg/array_constructor_11.f90 -O1 execution test > My mistake. This comes from a typo in trans.c (a EQ_EXPR instead of an > NE_EXPR). Could you test this patch? Works for me. Dave
Subject: Bug 33592 Author: fxcoudert Date: Sat Nov 10 18:02:18 2007 New Revision: 130072 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=130072 Log: PR fortran/33592 * trans.c (gfc_call_realloc): Fix the logic and rename variables. Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/trans.c
Problem fixed. Thanks for investigating this, Dave!