Silverfrost Forums

Welcome to our forums

error 144 - Type has been declared but ... :: a bug?

24 Jul 2015 3:22 #16643

A customer sent me the following source code. When FTN95 compiles it the error 144 is output, although we can't see that there is anything faulty. We have checked with other compilers, which didn't complain:

module type1_module

 private
 public type1

 type :: type1
    integer                           :: id
 end type type1

end module type1_module

!----------------------------------------------------------

module module1

 private
 public msg_len
 public func1 ! delete this line and the error is gone

 integer, parameter :: msg_len=256

 contains

! if this function is deleted the error is gone
function func1(t1_inst1) result(ierr)
  use type1_module, only: type1
  type(type1), intent(in) :: t1_inst1
  integer:: ierr
  ierr=0
end function func1

end module module1

!----------------------------------------------------------

module module2

 use module1, only: msg_len

! if the following 2 lines are activated -> no error
 !  private
  ! public msg

 character(len=msg_len) :: msg

end module module2

!----------------------------------------------------------

program main

  use type1_module, only: type1
  use module2, only: msg

  type(type1) :: t1_inst2

  msg='Main running...' !ftn95 v7.20 error: Type TYPE(TYPE1) has been declared but not defined
  write(6,*) msg
  t1_inst2%id=2  !ftn95 v5.40 error: id is not a component of TYPE1


end program main

You will have noticed a few comments. For example, if you delete line 19, the error 144 is gone. This is definitely strange. Please check.

Thank you.

Joerg Kuthe www.qtsoftware.com

25 Jul 2015 2:55 #16644

Changing the order of the USE statements at line 52:53 also removes the problem. . program main

   use module2, only: msg 
   use type1_module, only: type1 

   type(type1) :: t1_inst2 

   msg='Main running...' !ftn95 v7.20 error: Type TYPE(TYPE1) has been declared but not defined 
   write(6,*) msg 
   t1_inst2%id=2  !ftn95 v5.40 error: id is not a component of TYPE1 


 end program main 

It looks to me that type1 is becoming private in module1, although %id is being recognised ?

private/public can cause problems I never fully understand, although it does appear to be a bug

John

25 Jul 2015 7:31 #16646

Joerg

Thank you for your post.

I have logged this as a bug that needs fixing.

8 Jun 2016 2:31 #17600

This has now been fixed for the next release.

Please login to reply.