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

--- Comment #10 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2012-06-30 
00:32:29 UTC ---
For completeness, in the case I give in Comment #9, I get

Operating system error: Cannot allocate memory
Memory allocation failed

I have instrumented a few places to see what we are getting with the original
test case included here:

integer(kind=8) :: s, r
open(unit=1, file='testsize.f90', status='old')
inquire(unit=1, size=s, recl=r)
print *, 'size=', s, ' recl=', r
end

And I get:

$ ./a.out 
In init_units()
max_offset set to 4294967295
In newunit(): 4294967295
Ping! recl=4294967295
 size=                  135  recl=                   -1

This confirms that we are setting the unit recl to a large number which is
printed as -1 when using signed output, but unsigned is what we might expect.

max_offset is calculated at run time as follows:

  /* Calculate the maximum file offset in a portable manner.
     max will be the largest signed number for the type gfc_offset.
     set a 1 in the LSB and keep a running sum, stopping at MSB-1 bit.  */
  max_offset = 0;
  for (i = 0; i < sizeof (max_offset) * 8 - 1; i++)
    max_offset = max_offset + ((gfc_offset) 1 << i);
  printf("max_offset set to %u\n", max_offset);

I think we can decide what to do differently after we get Comment #7 feedback.

In the meantime, I will be looking at what we are doing wrong in the case of
Comment #9, maybe a separate bug.

Reply via email to