https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128566

            Bug ID: 128566
           Summary: Bogus errmsg on failed allocation
           Product: gcc
           Version: 16.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: henri at henrimenke dot de
  Target Milestone: ---

Trying to allocate something that's way too large (here 2 PiB) sets the errmsg
specifier to "Attempt to allocate an allocated object" which makes no sense.
This was previously reported, but the fix seems to have been incomplete:

- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91300

Live example: https://godbolt.org/z/j93dca9Yn



program gfortran_overflow_errmsg
  use iso_fortran_env, only: int64, real64
  implicit none
  real(real64), allocatable :: a(:)
  integer(int64) :: n
  integer :: stat
  character(len=100) :: msg
  n = 2_int64**62
  allocate(a(n), stat=stat, errmsg=msg)
  print '(a,i0,2a)', 'stat=', stat, ' errmsg=', trim(msg)
end program gfortran_overflow_errmsg

Reply via email to