With gfortran 12.4.0, 13.3.0, and 14.2.0, the program below prints
"T".   With gfortran 15, the program crashes with an error message
that indicates that a pointer is being freed that was not allocated.

% cat all.f90
  implicit none

  type string_t
    character(len=:), allocatable :: string_
  end type

  print *, true([string()])

contains

  type(string_t) function string()
    string%string_ = ""
  end function

  logical elemental function true(rhs)
    class(string_t), intent(in) :: rhs
    true = .true.
  end function

end

% gfortran all.f90
% ./a.out

a.out(28435,0x209bdc840) malloc: *** error for object 0x600002f98060:
pointer being freed was not allocated
a.out(28435,0x209bdc840) malloc: *** set a breakpoint in
malloc_error_break to debug

Program received signal SIGABRT: Process abort signal.

Backtrace for this error:
#0  0x1028d2563
#1  0x1028d14e3
#2  0x1a02a2de3
#3  0x1a026bf6f
#4  0x1a0178907
#5  0x1a0081e37
#6  0x1a00859bb
#7  0x1a00a4143
#8  0x102583bdf
#9  0x102583daf
zsh: abort      ./a.out

% gfortran --version
GNU Fortran (GCC) 15.0.1 20250315 (experimental)

Reply via email to