# Errors using certain Fortran compilers in CRAN checks

**URL:** <https://fortran-lang.discourse.group/t/errors-using-certain-fortran-compilers-in-cran-checks/8124>\
**Category:** Help\
**Created:** [June 1, 2024, 10:06pm UTC](https://fortran-lang.discourse.group/t/errors-using-certain-fortran-compilers-in-cran-checks/8124 "2024-06-01T22:06:50Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![ivanpribec](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ivanpribec/32/3290_2.png) [@ivanpribec](https://fortran-lang.discourse.group/u/ivanpribec)\
**Post date:** [June 1, 2024, 11:10pm UTC](https://fortran-lang.discourse.group/t/errors-using-certain-fortran-compilers-in-cran-checks/8124/4 "2024-06-01T23:10:33Z")

</div>

> [@jomulder](#):
>
> free(): invalid next size (fast)

According to StackOverflow this error is typical for a double-free, i.e. trying to free a null pointer. Somehow I doubt this error is related to this procedure.

> [@jomulder](#):
>
> The choice of the use of these kinds `i6` and `r15` was based on recent recommendations that I found when using fortran subroutines for R packages on CRAN.

As noted in the R docs, it’s important your types have the same storage width (and representation): [Writing R Extensions](https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Portable-Fortran-code-1)

[My own recommendation](https://fortran-lang.discourse.group/t/should-0-0-0-0-be-nan/7527/15) would be to just use the C kind specifiers matching whatever R uses and pack those into a module:

```fortran
module rkinds
   use, intrinsic :: iso_c_binding
   private
   integer, parameter, public :: rint = c_int
   integer, parameter, public :: rdp = c_double
end module

subroutine estimate_bct_ordinal(samsize0,numG,P,CDrawsStore)
use rkinds, only: rint, rdp
implicit none
integer(rint), intent(in) :: P, numG, samsize0
real(rdp), intent(out) :: CDrawsStore(samsize0,numG,P,P)
real(rdp) :: CCan(P,P)

! ...
end subroutine estimate_bct_ordinal

```

On my Mac, and using gfortran, the values of `rint` and `i6` are the same in practice, however the intent w.r.t the goal of interoperating with the canonical R implementation is different.

---

_[View the full topic](https://fortran-lang.discourse.group/t/errors-using-certain-fortran-compilers-in-cran-checks/8124)._
