From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 109948 invoked by alias); 27 Jul 2015 18:45:51 -0000 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 Received: (qmail 109858 invoked by uid 48); 27 Jul 2015 18:45:48 -0000 From: "mikael at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/64921] [4.9/5/6 Regression] FAIL: gfortran.dg/class_allocate_18.f90 Date: Mon, 27 Jul 2015 18:45:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mikael at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.9.4 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-07/txt/msg02371.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64921 Mikael Morin changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mikael at gcc dot gnu.org --- Comment #20 from Mikael Morin --- (In reply to Richard Biener from comment #19) > So the question is whether the frontend emits the correct test against zero: > > offset = offset * byte_stride; > D.3466 = (void *) array->data; > D.3467 = D.3466; > D.3465 = 8; > D.3469 = 8; > __builtin_memcpy ((void *) &transfer.4, (void *) > &D.3467, (unsigned long) MAX_EXPR , 0>); > ptr2 = (struct t4 *) (transfer.4 + offset); > if (ptr2 != 0B) > { > { > integer(kind=4) stat.5; > > if (ptr2->k == 0B) > > to me it looks like if we really want to test transfer.4 (array->data) > against > zero. transfer.4 + offset calculates the address of an element of an array. I believe that if that code is executed, array.data is non-zero, and of course array.data + offset as well. I think the the test should check for ptr2%j's nullness before deallocating ptr2%j, instead of testing ptr2. With a patch like this: diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c index 218973d..1ff7437 100644 --- a/gcc/fortran/class.c +++ b/gcc/fortran/class.c @@ -967,7 +967,7 @@ finalize_component (gfc_expr *expr, gfc_symbol *derived, gfc_component *comp, cond->block->expr1->ts.kind = gfc_default_logical_kind; cond->block->expr1->value.function.isym = gfc_intrinsic_function_by_id (GFC_ISYM_ASSOCIATED); cond->block->expr1->value.function.actual = gfc_get_actual_arglist (); - cond->block->expr1->value.function.actual->expr = gfc_copy_expr (expr); + cond->block->expr1->value.function.actual->expr = gfc_copy_expr (e); cond->block->expr1->value.function.actual->next = gfc_get_actual_arglist (); cond->block->next = dealloc; Unfortunately, it doesn't seem to fix the problem.