[Fortran] PR 34482: RFC and patch: BOZ to real/complex conversion for some systems

Jerry DeLisle jvdelisle@verizon.net
Wed Dec 19 04:16:00 GMT 2007


Tobias Burnus wrote:
> Assume for the following that 4 is the default integer/real kind and 8
> the largest integer kind. In DATA
>     z'FFFFFFFF'
> is has the largest integer kind and is thus identically to
>     z'00000000FFFFFFFF'
> If one now transfers this to a default-kind real, i.e.
>     real(z'FFFFFFFF')
> one transfers an 8 to a 4 byte variable. Depending on the system only
> the zeros (00000000) or the ones (FFFFFFFF) are transferred.
> 
> I think everyone would expect in this case that the ones/FFFFFFFF are
> bit-wise transferred, which the attached patch does by converting the
> BOZ to the smallest possible kind; for the example this is 4. This fixes
> the PR.
> 
> 
> However, I am not sure it does the right thing on all systems for:
>     real(z'00000000FFFFFFFF',kind=8)
> If one converts this to kind 4 ("z'FFFFFFFF'") and transfers it then,
> one might get FFFFFFFF00000000 on some sytems instead of
> 00000000FFFFFFFF. -- Or not?
> 
> Jerry, can you check that the patch does the right thing on such
> platforms and  real(z'00000000FFFFFFFF',kind=8) ?
> 
On the second, fixed patch, that you submitted with ppc64 linux:

   print *, real(z'FFFFFFFF', 4)
   print *, transfer(4294967295_8, 0.0_4)
   print '(z12)', transfer(real(z'FFFFFFFF',4), 1_4)
   print *, transfer(2143289344_8, 0.0_4)
   print '(z12)', transfer(real(z'7FC00000',4), 1_4)
   print *, real(z'7FC00000',4)
   print *, real(z'00000000ffffffff',8)
   print *, real(z'FFFFFFFF00000000',8)
   END

  $ gfc -fno-range-check nantest.f90
  $ ./a.out
              NaN
    0.0000000
     7FC00000
    0.0000000
     7FC00000
              NaN
   2.12199579096527232E-314
                        NaN

boz_9.f90 fails:

Running /home/jerryd/gcc/gcc43/gcc/testsuite/gfortran.dg/dg.exp ...
FAIL: gfortran.dg/boz_9.f90 (test for excess errors)
WARNING: gfortran.dg/boz_9.f90 compilation failed to produce executable
FAIL: gfortran.dg/boz_9.f90 (test for excess errors)
WARNING: gfortran.dg/boz_9.f90 compilation failed to produce executable
FAIL: gfortran.dg/boz_9.f90 (test for excess errors)
WARNING: gfortran.dg/boz_9.f90 compilation failed to produce executable
FAIL: gfortran.dg/boz_9.f90 (test for excess errors)
WARNING: gfortran.dg/boz_9.f90 compilation failed to produce executable
FAIL: gfortran.dg/boz_9.f90 (test for excess errors)
WARNING: gfortran.dg/boz_9.f90 compilation failed to produce executable
FAIL: gfortran.dg/boz_9.f90 (test for excess errors)
WARNING: gfortran.dg/boz_9.f90 compilation failed to produce executable
FAIL: gfortran.dg/boz_9.f90 (test for excess errors)
WARNING: gfortran.dg/boz_9.f90 compilation failed to produce executable



More information about the Fortran mailing list