# Nightly build CI failing because rand(UnitRange) changed (when to care?)

**URL:** <https://discourse.julialang.org/t/nightly-build-ci-failing-because-rand-unitrange-changed-when-to-care/49857>\
**Category:** New to Julia\
**Created:** [November 9, 2020, 5:35pm UTC](https://discourse.julialang.org/t/nightly-build-ci-failing-because-rand-unitrange-changed-when-to-care/49857 "2020-11-09T17:35:28Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [November 9, 2020, 7:02pm UTC](https://discourse.julialang.org/t/nightly-build-ci-failing-because-rand-unitrange-changed-when-to-care/49857/10 "2020-11-09T19:02:22Z")

</div>

Uhm… but there is something tricky here.

I was using simply `rand()` to generate random numbers, but to add the possibility of using optionally `StableRNGs` I have to use `rand(rng)`. I changed the code to do that, but the problem is that now it allocates memory:

```julia
julia> import Random

julia> rand()
0.30815646522353957

julia> @allocated rand()
0

julia> rng = Random.MersenneTwister(1);

julia> rand(rng)
0.23603334566204692

julia> @allocated rand(rng)
16

```

Thus, to have the option of passing a different `rng ` to `rand()` for some reason it allocates memory even if the option is the default one (and, as I mentioned, I need to generate tenths of thousands of random numbers, so this is really an issue, the code was free from allocations without that).

Edit: Well if I declare `rng` as constant, that allocation goes away. I will see if I can adapt that to my case.

---

_[View the full topic](https://discourse.julialang.org/t/nightly-build-ci-failing-because-rand-unitrange-changed-when-to-care/49857)._
