Skip to content

[Flang] Allocation is executed even if character length of allocate-object differs from character length specified by SOURCE specifier in allocate statement #112280

@ohno-fj

Description

@ohno-fj
Version of flang-new : 20.0.0(7f65377880ce6a0e5eaa4cb2591b86b8c8a24ee6)/AArch64

Allocation is executed even if character length of allocate-object differs from character length specified by SOURCE= in allocate statement.

The following are the test program, Flang-new, Gfortran and ifx compilation/execution result.

sngg310d_22.f90:

program main
  character(1),allocatable::ch
  call s1(ch)
  print *,'pass'
contains
  subroutine s1(aaa)
    character(*),allocatable::aaa
    allocate(aaa,source="123",stat=i)
    write(6,*) "allocated(aaa) = ", allocated(aaa)
    write(6,*) "stat = ", i
  end subroutine s1
end program main
$ flang-new sngg310d_22.f90; ./a.out
 allocated(aaa) =  T
 stat =  0
 pass
$
$ gfortran sngg310d_22.f90; ./a.out
 allocated(aaa) =  T
 stat =            0
 pass
$
$ ifx sngg310d_22.f90; ./a.out
 allocated(aaa) =  F
 stat =           14
 pass
$

Metadata

Metadata

Assignees

No one assigned

    Labels

    flangFlang issues not falling into any other categoryquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions