Skip to content

?LARF1F and ?LARF1L have no quick return for M = 0 (SIDE = 'L') or N = 0 (SIDE = 'R') #1430

Closed

Description

@kyungminlee

Called with SIDE = 'L' and M = 0, SLARF1F should do nothing. It has no quick return for that case, so it goes on with LASTV = 0. The loop on line 175 then indexes V(0), and ILASLC, called with M = 0, indexes C(0,N). Both are out of bounds. Next SGEMV is called with -1 rows, and it calls XERBLA.

DO WHILE( LASTV.GT.1 .AND. V( I ).EQ.ZERO )

SIDE = 'R' with N = 0 is the same with rows and columns swapped. DLARF1F, CLARF1F and ZLARF1F do exactly the same. ?LARF1L does not index V(0), since its loop condition is false at once, but it makes the same ILA?LC call and the same ?GEMV call. DLARF1L alone skips its BLAS calls when LASTV is 0 and returns with C unchanged, but it still indexes C(0,N).

Here is a small example that should print C = 1. Instead SGEMV calls XERBLA.

program larf1f_empty
  real :: v(1) = 1, c(1) = 1, work(1) = 0
  call slarf1f('L', 0, 1, v, 1, 1.0, c, 1, work)
  print *, 'C =', c
end program

One fix is to start with IF( M.LE.0 .OR. N.LE.0 ) RETURN, as ?LARFB does.

Activity

  1. langou commented on Oct 1, 2026

    @langou
    Contributor

    Thanks for pointing to this. Can you send a PR for all eight routines?

  2. langou commented on Oct 19, 2026

    @langou
    Contributor

    Fixed by #1435. Thanks @kyungminlee !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions