Skip to content
Snippets Groups Projects

Avoid an out-of-bounds read in the uniq example

Merged Sergey Kosukhin requested to merge bound-check-wa into master

Apparently, the Fortran standard does not enforce the short-circuit evaluation. Although gfortran performs it at the optimization levels -O1 and higher, the runtime out-of-bounds check, generated with the -fbounds-check compiler flag, works as if there were no short-circuiting. Therefore, IF (k == 1 .OR. ... OutputArray(k - 1) ... results in Fortran runtime error: Index '0' of dimension 1 of array 'outputarray' below lower bound of 1 when k == 1.

This MR makes the code (in a rather awkward way) independent of the short-circuit optimizations to avoid possible out-of-bounds memory access. Additionally, CI jobs that test with gfortran now build with the -fbounds-check Fortran compiler flag.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Loading
Please register or sign in to reply
Loading