[Bug fortran/83224] creating character array from elements shorter than declared does not pad with whitespace properly and aborts
urbanjost at comcast dot net
gcc-bugzilla@gcc.gnu.org
Thu Nov 30 13:48:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83224
--- Comment #2 from urbanjost at comcast dot net ---
Thanks for checking on this so quickly. I did not reduce my example any further
than I did because it would just print without padding with blanks the way I
expected and not abort if I made it shorter; using your reduced test and just
trying a few times I see that the abort occurs when the new length is 9 and the
previous length was 8 or less. I added back a few lines to demonstrate just in
case that is significant, maybe a second problem (ignore otherwise)?
[one ][two ][three]
[GOT HERE][onetwtwo][twoththr][threethr][three ]
Program received signal SIGABRT: Process abort signal.
Backtrace for this error:
JSU@buzz ~
$ cat yyy.f90
program dusty_corner ! exercise f2008 CHARACTER features
implicit none
character(len=:),allocatable :: words(:)
character(len=:),allocatable :: words1(:), words2(:)
words1=[character(len=3) :: 'one', 'two']
words2=[character(len=5) :: words1, 'three']
write(*,'(5("[",a,"]":))')words2
words=[character(len=3) :: 'one', 'two']
words=[character(len=5) :: words, 'three']
words=[character(len=8) :: words, 'three'] ! ADD: ok with len=8
write(*,'(5("[",a,"]":))')'GOT HERE',words ! ADD: keeps going
words=[character(len=9) :: words, 'three'] ! ADD: actually crashes
write(*,'(5("[",a,"]":))')'DID NOT GET HERE',words ! ADD:
end program dusty_corner
More information about the Gcc-bugs
mailing list