This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix fortran/81509


On Thu, Sep 28, 2017 at 10:46:06AM +0100, Paul Richard Thomas wrote:
> 
> I'll take your word for it on the F2008 contraints. Given that the
> patch is very good - OK for trunk.
> 

The text for IAND from F2008 is 

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.

Result Characteristics.

Same as I if I is of type integer; otherwise, same as 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.


Prior to my patch one could do IAND(1_4, 4_8).  gfortran would convert 
the 1_4 to 1_8 and return effectively IAND(1_8, 4_8).  This violates 
the 2nd sentence in the description of J.  One might argue that the 
extension makes sense except the documentation does not state what
occurs.  The real problem comes with IAND(42_2,z'DEAD') where 
z'DEAD' is some mask user wants to apply to an INTEGER(2) entity.
On x86_64 and due to the implementation of a BOZ to statisfy 
requirements of the DATA statement from F95, z'DEAD' is implicitly an
INTEGER(16).  So, IAND(42_2,z'DEAD') convert 42_2 to 42_16 and returns
a INTEGER(16).  This is a violation of F2008 'Result Value' statement.

In hindsight, some 13 years ago I should have introduced a BT_BOZ basic
type definition.  I need to check, but at one time gfortran for a boz
literal constant set x->is_boz=1, x->ts.type=BT_INTEGER, and x->ts.kind=16. 
where x is a gfc_expr *.  The is_boz is unneeded with BT_BOZ and the
kind can be set to the appropriate kind when needed.  A bonus with
BT_BOZ would automatic fix all other intrinsics which currently accept
a boz, e.g., ABS(z'DEAD').

-- 
Steve
20170425 https://www.youtube.com/watch?v=VWUpyCsUKR4
20161221 https://www.youtube.com/watch?v=IbCHE-hONow


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]