This is the mail archive of the gcc-help@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: How to do this in gfortran


On 01/28/2013 10:14 AM, Tim Prince wrote:
On 01/28/2013 09:02 AM, Mark Hounschell wrote:
I am porting some very old code. I have many things like below in this
code


program test implicit none

       integer*1 ivalx1
       integer*2 ivalx2
       integer*4 ivalx4

       parameter (ivalx1 = x'80')
       parameter (ivalx2 = x'8000')
       parameter (ivalx4 = x'80000000')

The compiler fails with:

f77 test.f
test.f:8.26:

       parameter (ivalx1 = x'80')
                          1
Error: Arithmetic overflow converting INTEGER(8) to INTEGER(1) at (1).
This check can be disabled with the option -fno-range-check
test.f:9.26:

       parameter (ivalx2 = x'8000')
                          1
Error: Arithmetic overflow converting INTEGER(8) to INTEGER(2) at (1).
This check can be disabled with the option -fno-range-check
test.f:10.26:

       parameter (ivalx4 = x'80000000')
                          1
Error: Arithmetic overflow converting INTEGER(8) to INTEGER(4) at (1).
This check can be disabled with the option -fno-range-check

I don't want to use the -fno-range-check option because I want to know
about the real ones. I don't understand why gfortran has issues with
this. They are certainly valid values for the the types specified. I
have been, just setting the values in the code section using the
'transfer' instrinsic but now I'm finding these in include files and I
would have to change every source file that used the particular
include file. I'm sure there is an easy solution. Could someone
enlighten me please.

Thanks and Regards
Mark
Perhaps you could arrange to make the constants come out as x'80'_1,
x'8000'_2, x'80000000'_4, or
-1_1, -1_2, -1_4.  The values you set aren't valid positive integer
values in the smaller type.


Why must it be a valid "positive integer"? How/why does the compiler even know/care whether I am going to use this data for an arithmetic operation or not. Even if I was, it should be up to me to be able to set the sign bit myself. x'80' is a valid negative integer*1 etc...


Regards
Mark


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