Dear all, it was already discussed in the above PRs that the testcase lrshift_1.f90 needs to be corrected because it invokes negative values of the SHIFT argument. This is fixed, as well as the related documentation, which did not match e.g. the Fortran standard. Looking closer at the actual implementation, it also turned out that the runtime implementation of SHIFTA/RSHIFT gave different (=wrong) results when SHIFT==BIT_SIZE(arg1). This is fixed and tested by the attached patches. I did not implement any run-time checks for the SHIFT argument. All previous undefined behavior stays the same. OK for trunk? Thanks, Harald 2019-06-13 Harald Anlauf PR fortran/90577 PR fortran/90578 * trans-intrinsic.c (gfc_conv_intrinsic_shift): Properly distinguish logical/arithmetic shifts. * intrinsic.texi: Update documentation for SHIFTR/SHIFTL/SHIFTA (Fortran 2008) and LSHIFT/RSHIFT (GNU extensions). 2019-06-13 Harald Anlauf PR fortran/90577 PR fortran/90578 * gfortran.dg/lrshift_1.f90: Adjust testcase. * gfortran.dg/shiftalr_3.f90: New testcase.