- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a question. See code below. I'm using a variable in one type in an initialization expression for another type. The first block compiles fine, as expected. The second one (which is using an extended type that contains the same data) throws a "error 7169: Bad initialization expression [BLAH]" if I don't use the var%base_type%name form to access the variable. Is this correct or a compiler bug? I can normally use var%name in other circumstances. Is there a reason that this is not allowed in this context?
program main implicit none type :: blah character(len=100) :: str = '' end type blah block type :: extended_type integer :: id = 0 character(len=100) :: name = '' end type extended_type type(extended_type),parameter :: var = extended_type(id=1, name='var') type(blah),parameter :: blah_var = blah(str=var%name) !compiles fine end block block type,abstract :: base_type integer :: id = 0 character(len=100) :: name = '' end type base_type type,extends(base_type) :: extended_type end type extended_type type(extended_type),parameter :: var = extended_type(id=1, name='var') type(blah),parameter :: blah_var1 = blah(str=var%base_type%name) !compiles fine type(blah),parameter :: blah_var2 = blah(str=var%name) !error 7169: bad initialization expression end block end program main
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What happens when you change name in base_type to nameB? (and change references to it too)
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Looks like a compiler bug to me. Hmm.. the code as shown generates an internal compiler error (ICE) with gfortran 5.0!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jim: same problem occurs if name is changed to nameb.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The same error occurs Jim. I tried a few other changes without any success either. I escalated this to Development (see internal tracking id below) and will keep you posted on their analysis.
(Internal tracking id: DPD200360691)

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page