- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm seeing something odd here. If I use STORAGE_SIZE on a CLASS(*) variable to initialize a character string using REPEAT, the result is different if I put the size in a temporary variable, or in the actual routine call. See below:
program test implicit none call bug(1) contains subroutine bug(k) use iso_fortran_env, only: CHARACTER_STORAGE_SIZE implicit none class(*),intent(in) :: k character(len=:),allocatable :: s1,s2 integer :: n n = storage_size(k)/CHARACTER_STORAGE_SIZE !works if size is put in temp variable s1 = repeat(' ', n) write(*,*) 'len(s1)=',len(s1) !prints 4 s2 = repeat(' ', storage_size(k)/CHARACTER_STORAGE_SIZE) !doesn't work! write(*,*) 'len(s2)=',len(s2) !prints 0 end subroutine bug end program test
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for reporting this and for the nice reproducer. It does appear the usage producing the incorrect results should work. I reported this to Development.
(Internal tracking id: DPD200378821)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page