Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

Bug in -assume realloc_lhs

$
0
0

Hi,

With the latest compiler, and the code below, I get garbage output.

program test_lhs_allocate

    use iso_fortran_env

    implicit none

    type :: table
        character(63) :: name = ''
        character(63), allocatable :: alias(:)
    end type

    integer :: i, j
    type(table), allocatable :: list(:)
    type(table) :: item

    allocate (list(1:0))    !empty list

    item%name = 'name'
    item%alias = [character(63) :: 'label']
    list = [list, item]

    item%name = 'id'
    item%alias = [character(63) :: ]
    list = [list, item]


    item%name = 'status'
    item%alias = [character(63) :: 'state', 'validity', 'test']
    list = [list, item]

    item%name = 'other'
    item%alias = [character(63) :: 'extra', 'additional', 'more']
    list = [list, item]


    do i = 1, SIZE(list)
        write (OUTPUT_UNIT, '(/"name: ", A,/,"aliases: ", *(A,:,","))') &
            TRIM(list(i)%name), &
            (TRIM(list(i)%alias(j)), j = 1, SIZE(list(i)%alias))
    enddo

end program test_lhs_allocate

This is the output I get with both ifort 15.0 and gfortran 4.9 (invalid characters trimmed from output when using ifort):

~$ ifort -standard-semantics test_lhs_allocate.f90
~$ ./a.out

name: name
aliases:

name: id
aliases:

name: status
aliases:                                ,                                         ?

name: other
aliases: extra,additional,more
~$ gfortran test_lhs_allocate.f90
~$ ./a.out

name: name
aliases: label

name: id
aliases:

name: status
aliases: state,validity,test

name: other
aliases: extra,additional,more

I'm not sure if I already reported this, so I apologize in advance if I did.

 


Viewing all articles
Browse latest Browse all 3270

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>