Bug 30135 - [Regression 4.3] Error without comp. initialization: Module variable with a comp. initialization must have SAVE
Summary: [Regression 4.3] Error without comp. initialization: Module variable with a c...
Status: RESOLVED WORKSFORME
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic, rejects-valid
Depends on:
Blocks:
 
Reported: 2006-12-10 09:14 UTC by Tobias Burnus
Modified: 2006-12-10 12:34 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2006-12-10 09:14:40 UTC
The following code does not contain a component initialization, nonetheless, gfortran emits the following error:

  type(myT) :: t
               1
Error: Module variable 't' at (1) with a default initialization must have the SAVE attribute

This constrain is checked in result.c, excerpt from that file:

  /* 4th constraint in section 11.3:  "If an object of a type for which
     component-initialization is specified (R429) appears in the
     specification-part of a module and does not have the ALLOCATABLE
     or POINTER attribute, the object shall have the SAVE attribute."  */


module good2
  implicit none
  type myT
     integer :: j  ! = 5.5
     integer, pointer :: p ! => null()
  end type myT
  type(myT) :: t
end module good2

program main
  use good2
  implicit none
  t%j = 15
  nullify(t%p)
end program main

(Interestingly, only g95 (and gfortran) give an error if one uses component initialization, NAG f95, sunf95 and ifort don't.)
Comment 1 Tobias Burnus 2006-12-10 12:34:43 UTC
Bootstapped & re-tested => Works now.