------- Comment #3 from jvdelisle at gcc dot gnu dot org  2006-09-14 01:21 
-------
Assembly output which does not work because it is using the same block of
memory for the st_parameter_dt structure for both WRITEs, the file position
pointer is in this structure, but not set before the calls because it is
suppose to be wherever it was left at.

        movl    $.LC1, -368(%ebp)
        movl    $13, -364(%ebp)
        movl    $11, -372(%ebp)
        movl    $0, -376(%ebp)
        leal    -376(%ebp), %eax
        movl    %eax, (%esp)
        call    _gfortran_st_write
snip

        movl    $.LC1, -368(%ebp)
        movl    $16, -364(%ebp)
        movl    $12, -372(%ebp)
        movl    $0, -376(%ebp)
        leal    -376(%ebp), %eax
        movl    %eax, (%esp)
        call    _gfortran_st_write

Assembly output with -O1 shows that in this case, two separate blocks of memory
are being used for the two separate st_parameter_dt structures.  In this case
the two writes are kept independent as they should be.

        movl    $.LC0, -324(%ebp)
        movl    $13, -320(%ebp)
        movl    $11, -328(%ebp)
        movl    $0, -332(%ebp)
        movl    %esi, -624(%ebp)
        movl    %esi, (%esp)
        call    _gfortran_st_write

snip

        movl    $.LC0, -600(%ebp)
        movl    $16, -596(%ebp)
        movl    $12, -604(%ebp)
        movl    $0, -608(%ebp)
        leal    -608(%ebp), %ebx
        movl    %ebx, (%esp)
        call    _gfortran_st_write

The STREAM I/O assumes that the dtp structure is global, static, and unique to
each unit.  Evidently this is not the case.  To fix this, we can allocate the
POS pointer for STREAM within the gfc_unit structure which is allocated at run
time when OPENed and will remain static and unique.

I will proceed with a patch to do this.


-- 

jvdelisle at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-09-14 01:21:46
               date|                            |


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

Reply via email to