From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17846 invoked by alias); 30 Jun 2009 12:57:30 -0000 Received: (qmail 17791 invoked by uid 48); 30 Jun 2009 12:57:14 -0000 Date: Tue, 30 Jun 2009 12:57:00 -0000 Message-ID: <20090630125714.17790.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug fortran/40598] Some missed optimizations in array assignment In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "pault at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2009-06/txt/msg02216.txt.bz2 ------- Comment #4 from pault at gcc dot gnu dot org 2009-06-30 12:57 ------- Modifying trans-expr (gfc_trans_zero_assign) to: tmp = build4 (ARRAY_RANGE_REF, TREE_TYPE (dest), dest, build_int_cst (gfc_array_index_type, 3), NULL_TREE, NULL_TREE); /* If we are zeroing a local array avoid taking its address by emitting a = {} instead. */ if (!POINTER_TYPE_P (TREE_TYPE (dest))) return build2 (MODIFY_EXPR, void_type_node, tmp, build_constructor (TREE_TYPE (tmp), NULL)); produces: array[3 ...] = {}; { struct __st_parameter_dt dt_parm.2; dt_parm.2.common.filename = &"test.f90"[1]{lb: 1 sz: 1}; dt_parm.2.common.line = 4; dt_parm.2.common.flags = 128; dt_parm.2.common.unit = 6; _gfortran_st_write (&dt_parm.2); for: integer :: array (3, 3) array = 1 array = 0 print *, array end and the output is: [prt@localhost tmp]# ./a.out 1 1 1 0 0 0 0 0 0 Segmentation fault So the lower bound for the reference seems to be OK but I have not understood how to set the upper bound. If I set argument three, the lower bound is reset to zero and the size of the array reference is determined by arg 3. This also gets rid of the seg fault. I obviously do not have the faintest idea of what I am doing! I notice as well that the ARRAY_RANGE_REF is not used very much. Paul -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40598