http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50753

             Bug #: 50753
           Summary: dshiftl/dshiftr: Rejects valid BOZ, accepts double BOZ
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid, rejects-valid
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: bur...@gcc.gnu.org
                CC: ka...@gcc.gnu.org


Found when checking PR fortran/50514:

gfortran rejects:

  integer :: I, J
  print *, dshiftl(z'FFF', J, (bit_size(j)+1))
  end

with
   Error: 'j' argument of 'dshiftl' intrinsic at (1) must
          be the same type and kind as 'i'

Expected:
a) The BOZ is accepted
b) There is a diagnostic as SHIFT is larger than BIT_SIZE(J).


The same applies to DSHIFTR.


>From Fortran 2008's 13.7.50 DSHIFTL (I, J, SHIFT)

"Arguments.

 I   shall be of type integer or a boz-literal-constant.
 J   shall be of type integer or a boz-literal-constant. If both I and J are
     of type integer, they shall have the same kind type parameter. I and J
     shall not both be boz-literal-constants.
 SHIFT  shall be of type integer. It shall be nonnegative and less than
     or equal to BIT SIZE (I) if I is of type integer; otherwise, it shall
     be less than or equal to BIT SIZE (J)."

 Result Value.   If either I or J is a boz-literal-constant, it is first
 converted as if by the intrinsic function INT to type integer with the kind
 type parameter of the other."

 * * *

Additionally, the following is accepted but invalid: Only one BOZ is allowed:

  print *, dshiftl(z'FFF', z'AAA', 0)
  end

I am not sure whether it should be allowed with -std=gnu, but none of my
compilers diagnoses it correctly. (Well, except for ifort, which even rejects
the example of the Fortran 2008 standard.)

Reply via email to