This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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]

[PATCH,gfortran] Re: Kind of constants in generic intrinsics


On Fri, Dec 16, 2005 at 08:32:03PM -0800, Steve Kargl wrote:
> On Fri, Dec 16, 2005 at 07:43:58PM -0800, Steve Kargl wrote:
>> On Sat, Dec 17, 2005 at 03:02:18AM +0100, Tobias Schl?ter wrote:
>>> Steve Kargl wrote:
>>>> This is essential what gfortran is doing. -fdump-parse-tree shows
>>>> 
>>>>       ASSIGN MAIN__:a 4294967295
>>>>       ASSIGN MAIN__:b 4294967295_8
>>> 
>>> FWIW this is wrong.  This should be
>>>  ASSIGN MAIN__:a -1
>>>  ASSIGN MAIN__:b -1_8
>>> as the bit sequence resulting from NOT(0) should be converted back
>>> to default integer, i.e. -1_4 before any further arithmetic is done
>>> during constant folding (NB this can't be right because 4294967295
>>> is not a valid value for an INTEGER*4).  We seem to be missing a call
>>> to twos_complement() in gfc_simplify_not, and probably in the
>>> simplification of other bit operation intrinsics, too.
>>> 
>> 
>> I have a one line patch that fixes this.  Thanks for the hint, Tobi.
>> 
> 
> Tobi, you're right.  IBSET suffers from a similar problem.  I'll
> also note that
> 
>    integer(kind=1) i1
>    i1 = not(0)
>    end
> 
> dies with an overflow error without the patch.
> 

The attached patch has been bootstrapped and regression tested
on i386-*-freebsd.  OK for trunk and 4.1 in 48 hours? 


2005-12-17  Steven G. Kargl  <kargls@comcast.net>
	    Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>

	PR fortran/25458
	* simplify.c (gfc_simplify_ibset, gfc_simplify_not): Add call to
	twos_complement.

	gfortran.dg/chkbits.f90: New test.

-- 
Steve

Attachment: simplify.c.diff
Description: Text document

Attachment: chkbits.f90
Description: Text document


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