# Most common run-time errors?

**URL:** <https://fortran-lang.discourse.group/t/most-common-run-time-errors/10755>\
**Category:** Uncategorized\
**Created:** [March 1, 2026, 8:55pm UTC](https://fortran-lang.discourse.group/t/most-common-run-time-errors/10755 "2026-03-01T20:55:58Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Beliavsky](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@Beliavsky](https://fortran-lang.discourse.group/u/Beliavsky)\
**Post date:** [March 2, 2026, 11:29am UTC](https://fortran-lang.discourse.group/t/most-common-run-time-errors/10755/5 "2026-03-02T11:29:09Z")

</div>

> [@davidpfister](#):
>
> merge(size(array), 0, allocated(array))

That is not safe either. You should assume that merge will evaluate both `tsource` and `fsource`. You need to use an `if` block. Because I have had the same problem with `size` I [proposed](https://github.com/j3-fortran/fortran_proposals/issues/219) making the size of an unallocated array -1. Peter Klausler suggested instead defining a safe wrapper for `size`

```fortran
module mySizeModule
contains
pure integer function mySize(x)
class(*), dimension(..), intent(in), optional :: x
mySize = -1
if (present(x)) mySize = size(x)
end function
end module

use mySizeModule
integer, allocatable :: a(:), b(
allocate(a(10))
print *, mySize(a), mySize(b)
end

```

A previous thread was [Size of an unallocated array](https://fortran-lang.discourse.group/t/size-of-an-unallocated-array/4633)

---

_[View the full topic](https://fortran-lang.discourse.group/t/most-common-run-time-errors/10755)._
