Bug 20845 - Module variablle with defualt component needs SAVE attribute.
Summary: Module variablle with defualt component needs SAVE attribute.
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.1.0
: P2 minor
Target Milestone: 4.1.0
Assignee: kargls
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2005-04-08 15:51 UTC by Joost VandeVondele
Modified: 2006-02-03 21:36 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-01-27 19:11:13


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joost VandeVondele 2005-04-08 15:51:54 UTC
The following is non-standard and the compiler should probably generate a
warning/error with '-pedantic -std=f95'

MODULE T1
 TYPE init_type
   integer :: i=1
 END TYPE init_type
 TYPE(init_type) :: x
END MODULE T1
END
Comment 1 Francois-Xavier Coudert 2005-04-09 19:19:56 UTC
OK, it took me time to see what was missing here, but the g95 error message is
rather clear:

"Module variable 'x' at (1) with default components must have the SAVE attribute"

Confirmed and marked as minor.
Comment 2 Tobias Schlüter 2005-04-22 14:17:05 UTC
I didn't find anything requiring this in the standard, and it would seem weird,
given that SAVE is implicit in several cases.  See also note 4.27.
Comment 3 Joost VandeVondele 2005-04-23 13:42:29 UTC
(In reply to comment #2)
> I didn't find anything requiring this in the standard, and it would seem 
weird,
> given that SAVE is implicit in several cases.  See also note 4.27.

4.4 : 'Unlike explicit initialization, default initialization does not imply 
that the object has the SAVE attribute' 

Comment 4 Tobias Schlüter 2005-04-23 13:53:16 UTC
(In reply to comment #3) 
> 4.4 : 'Unlike explicit initialization, default initialization does not imply 
> that the object has the SAVE attribute'

So?  I still don't see why this is invalid.  The error message FX quoted still
doesn't make any more sense to me.  What am I missing?
Comment 5 Joost VandeVondele 2005-04-23 14:03:26 UTC
(In reply to comment #4)

> doesn't make any more sense to me.  What am I missing?

a constraint in 11.3
Comment 6 kargls 2006-01-27 19:11:13 UTC
I working on a patch for this.
Comment 7 kargls 2006-02-03 21:32:32 UTC
Subject: Bug 20845

Author: kargl
Date: Fri Feb  3 21:32:14 2006
New Revision: 110560

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110560
Log:
2006-02-03  Steven G. Kargl  <kargls@comcast>
            Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/20845
        * resolve.c (resolve_symbol): Default initialization of derived type
        component reguires the SAVE attribute.

2006-02-02  Steven G. Kargl  <kargls@comcast>

        PR fortran/24958
        match.c (gfc_match_nullify):  Free the list from head not tail.

        PR fortran/25072
        * match.c (match_forall_header): Fix internal error caused by bogus
        gfc_epxr pointers.


2006-02-03  Steven G. Kargl  <kargls@comcast.net>

        PR fortran/24958
        * gfortran.dg/nullify_2.f90

        PR fortran/20845
        * gfortran.dg/char_result_11.f90: Add SAVE.
        * gfortran.dg/der_pointer_4.f90: Ditto.
        * gfortran.dg/used_dummy_types_5.f90
        * gfortran.dg/default_initialization.f90: New test.



Added:
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/default_initialization.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/nullify_2.f90
Modified:
    branches/gcc-4_1-branch/gcc/fortran/ChangeLog
    branches/gcc-4_1-branch/gcc/fortran/match.c
    branches/gcc-4_1-branch/gcc/fortran/resolve.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/char_result_11.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/der_pointer_4.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/used_dummy_types_5.f90

Comment 8 kargls 2006-02-03 21:36:13 UTC
Fixed in 4.1 and trunk