From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jim Wilson To: egcs@cygnus.com Subject: Re: f771 dies with trivial fortran code Date: Wed, 20 Aug 1997 19:30:07 -0000 Message-id: <199708201930.MAA23421@cygnus.com> In-reply-to: f771 dies with trivial fortran code X-SW-Source: 1997-08/0219.html This is due to a backend change made since gcc 2.7.2. Some code was added to handle C++ destructors inside conditional expressions differently than they used to be handled. This apparently was necessary for correct behaviour, though I don't know exactly what bug was being fixed. (Perhaps destructors were always run, even if the variable was only constructed on one side of the conditional expression?) Anyways, this causes problems if a conditional expression appears inside the type expression of a parameter. The code expects us to always have a binding contour, but we do not have one when parsing the parameters. Since no destructors are possible in this case, it is safe for us to do nothing. A C testcase: sub (int a, int b, int c[a > b ? a : b]) { } A Fortran testcase: subroutine foo () character*(*) str c return c entry bar (str) str = 'a' c ^^^^^^^^ culprit return end c I have checked in this patch to fix the problem. Wed Aug 20 11:58:33 1997 Jim Wilson * stmt.c (start_cleanup_deferal, end_cleanup_deferal): Test block_stack before dereferencing it. Index: stmt.c =================================================================== RCS file: /cvs/cvsfiles/egcs/stmt.c,v retrieving revision 1.1.1.1 diff -p -r1.1.1.1 stmt.c *** stmt.c 1997/08/11 15:57:13 1.1.1.1 --- stmt.c 1997/08/20 18:43:30 *************** expand_cleanups (list, dont_do, in_fixup *** 4212,4218 **** void start_cleanup_deferal () { ! ++block_stack->data.block.conditional_code; } /* Mark the end of a conditional region of code. Because cleanup --- 4212,4221 ---- void start_cleanup_deferal () { ! /* block_stack can be NULL if we are inside the parameter list. It is ! OK to do nothing, because cleanups aren't possible here. */ ! if (block_stack) ! ++block_stack->data.block.conditional_code; } /* Mark the end of a conditional region of code. Because cleanup *************** start_cleanup_deferal () *** 4223,4229 **** void end_cleanup_deferal () { ! --block_stack->data.block.conditional_code; } /* Move all cleanups from the current block_stack --- 4226,4235 ---- void end_cleanup_deferal () { ! /* block_stack can be NULL if we are inside the parameter list. It is ! OK to do nothing, because cleanups aren't possible here. */ ! if (block_stack) ! --block_stack->data.block.conditional_code; } /* Move all cleanups from the current block_stack