This program intentionally tries to allocate an allocated variable. A failed allocate should not change the input value, but the length of the variable is changed from 5 to 132 characters by being padded on the right with nulls (NOT spaces). gfortran and ifort leave the variable three characters in length.
program testit
implicit none
character(len=:),allocatable :: line
character(len=256) :: message
integer :: istat
line=‘abc’
message=’’
allocate(character(len=132):: line,errmsg=message,stat=istat)
if(istat.ne.0)write(,)trim(message)
write(,)‘allocated?’,allocated(line),‘len=’,len(line)
line=‘xxxxx’
write(,)len(line)
end program testit