[Patch, Fortran, F08] PR 55207: Variables declared in the main program should implicitly get the SAVE attribute
Janus Weil
janus@gcc.gnu.org
Sun Mar 16 18:40:00 GMT 2014
>> (1) The test in pr47399 comment 0 gives an ICE:
>>
>> pr47399.f90: In function 'test':
>> pr47399.f90:32:0: internal compiler error: in gfc_trans_auto_array_allocation, at fortran/trans-array.c:5682
>> integer, dimension (a_const%i()) :: x ! #3
>
> I can confirm this. Will investigate.
Ok, my first impulse to fix this was ...
Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c (revision 208590)
+++ gcc/fortran/decl.c (working copy)
@@ -3831,7 +3831,8 @@
implicitly have the SAVE attribute. */
if ((gfc_current_state () == COMP_MODULE
|| gfc_current_state () == COMP_PROGRAM)
- && !current_attr.save && (gfc_option.allow_std & GFC_STD_F2008) != 0)
+ && !current_attr.save && (gfc_option.allow_std & GFC_STD_F2008) != 0
+ && current_attr.flavor != FL_PARAMETER)
current_attr.save = SAVE_IMPLICIT;
colon_seen = 1;
... which unfortunately does not help. Second I simply removed the
assert which causes the ICE ...
Index: gcc/fortran/trans-array.c
===================================================================
--- gcc/fortran/trans-array.c (revision 208590)
+++ gcc/fortran/trans-array.c (working copy)
@@ -5679,7 +5679,6 @@
type = TREE_TYPE (type);
gcc_assert (!sym->attr.use_assoc);
- gcc_assert (!TREE_STATIC (decl));
gcc_assert (!sym->module);
if (sym->ts.type == BT_CHARACTER
... which actually helps (i.e. it removes the ICE and makes the
example work correctly at runtime). Third I looked at the dump that is
generated:
integer(kind=8) ubound.0;
integer(kind=8) size.1;
static integer(kind=4)[0:D.2341] * restrict x;
integer(kind=8) D.2341;
bitsizetype D.2342;
sizetype D.2343;
void * restrict D.2345;
integer(kind=8) D.2344;
try
{
ubound.0 = (integer(kind=8)) get_i ();
size.1 = NON_LVALUE_EXPR <ubound.0>;
size.1 = MAX_EXPR <size.1, 0>;
D.2341 = size.1 + -1;
D.2342 = (bitsizetype) (sizetype) NON_LVALUE_EXPR <size.1> * 32;
D.2343 = (sizetype) NON_LVALUE_EXPR <size.1> * 4;
D.2344 = size.1 * 4;
D.2345 = (void * restrict) __builtin_malloc (MAX_EXPR <(unsigned
long) D.2344, 1>);
x = (integer(kind=4)[0:D.2341] * restrict) D.2345;
What looks funny to me is that the ubound in the declaration of x
(i.e. 'D.2341') is set only some time after that declaration. This
makes me wonder whether the ICE we're seeing is just a symptom of a
dormant wrong-code problem here? I think I need to take a closer look
at the PR again to understand what's going on ...
Cheers,
Janus
More information about the Fortran
mailing list