For empty matrices the workspace query returns 0.0 but 0 is an illegal value for lwork. See the following program where I also show the result from dsyev
program test
implicit none
integer*8 :: lwork, info, ipiv(0)
double precision :: a(0,0), w(0), work(1)
lwork = -1_8
call dsyev('N', 'U', 0_8, a, 1_8, w, work, lwork, info)
write(*,*) work
lwork = -1_8
call dsytrf('U', 0_8, a, 1_8, ipiv, work, lwork, info)
write(*,*) work
end program test

