The code generated to call RANDOM_SEED doesn't take into account the existence
of a possible default integer kind other than 4. For example:

$ cat o.f90
  integer :: i, j(8)
  call random_seed (size=i)
  print *, i
  call random_seed (get=j)
  print *, j
  call random_seed (put=j)
  end
$ gfortran o.f90 -fdefault-integer-8 -fdump-tree-original && ./a.out
                    8
  1556651063369256213  1358030301163568053  1969796612819413169 
1882033285047892425                    0                    0                  
 0                    0

and the tree dump clearly shows that wrong type arguments are passed to
_gfortran_random_seed, which would lead to worst things on big-endian
platforms:

  int8 j[8];
  int8 i;
 _gfortran_random_seed (&i, 0B, 0B);


I think it would be not to hard to make two different library functions, one
for int4 and the other one for int8. The int8 would then report a SIZE of the
seed that is half the size for int4, and that should do the trick.

Thomas, any opinion on that?


-- 
           Summary: RANDOM_SEED is broken with -fdefault-integer-8
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fxcoudert at gcc dot gnu dot org


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

Reply via email to