Skip to content

Avoid undefined behavior in Random_int by having it always return 0 for n = 0.#5206

Merged
atmyers merged 2 commits intoAMReX-Codes:developmentfrom
atmyers:random0
Mar 17, 2026
Merged

Avoid undefined behavior in Random_int by having it always return 0 for n = 0.#5206
atmyers merged 2 commits intoAMReX-Codes:developmentfrom
atmyers:random0

Conversation

@atmyers
Copy link
Copy Markdown
Member

@atmyers atmyers commented Mar 17, 2026

amrex::Random_int(0, engine) currently causes undefined behavior that was leading to a hang on Perlmutter. This avoids this by early exiting if n = 0.

Summary

Additional background

Checklist

The proposed changes:

  • fix a bug or incorrect behavior in AMReX
  • add new capabilities to AMReX
  • changes answers in the test suite to more than roundoff level
  • are likely to significantly affect the results of downstream AMReX users
  • include documentation in the code and/or rst files, if appropriate

@atmyers atmyers requested a review from WeiqunZhang March 17, 2026 16:02
@atmyers atmyers enabled auto-merge (squash) March 17, 2026 20:09
@atmyers atmyers merged commit f546b59 into AMReX-Codes:development Mar 17, 2026
74 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants