public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/24305]  New: Complex(10) formatted IO is broken.
@ 2005-10-11  5:50 jblomqvi at cc dot hut dot fi
  2005-10-11  5:55 ` [Bug libfortran/24305] " jblomqvi at cc dot hut dot fi
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: jblomqvi at cc dot hut dot fi @ 2005-10-11  5:50 UTC (permalink / raw)
  To: gcc-bugs

The problem is that the IO routines assume kind==size, and complex numbers are
handled as two reals, advancing a pointer between doing the IO. For types with
padding such as complex(10) this breaks as the pointer is advanced 10 bytes
instead of 12 (or 16 on IA64, x86-64).

It should be noted that the patch proposed for 24174 also fixes complex(10)
formatted output.


-- 
           Summary: Complex(10) formatted IO is broken.
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libfortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jblomqvi at cc dot hut dot fi
GCC target triplet: i686-pc-linux-gnu


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libfortran/24305] Complex(10) formatted IO is broken.
  2005-10-11  5:50 [Bug libfortran/24305] New: Complex(10) formatted IO is broken jblomqvi at cc dot hut dot fi
@ 2005-10-11  5:55 ` jblomqvi at cc dot hut dot fi
  2005-11-05 18:08 ` jblomqvi at cc dot hut dot fi
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jblomqvi at cc dot hut dot fi @ 2005-10-11  5:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from jblomqvi at cc dot hut dot fi  2005-10-11 05:55 -------
Consider this testcase (from 24174):

! { dg-do run }
! PR 24174
program kind10_io
  real(kind=10) :: a,b(2), c
  complex(kind=10) :: d, e, f(2)
  character(len=180) :: tmp
  ! Test real(10) scalar and array formatted IO
  b(:) = 2.0_10
  write (tmp, *) b
  read (tmp, *) a, c
  if (a /= 2.0_10) call abort()
  if (c /= 2.0_10) call abort()
  ! Complex(10) scalar and array formatted and list formatted IO
  f = cmplx ( 1.0_10, 2.0_10, 10)
  d = cmplx ( huge (1.0_10), huge (2.0_10), 10)
  write (tmp, *) d
  read (tmp, *) e ! List formatted read doesn't work.
  if (e /= d) call abort()
  write (tmp, '(2(e12.4e5, 2x))') d
  read (tmp, '(2(e12.4e5, 2x))') e ! Read doesn't work either
  if (e /= d) call abort()
end program kind10_io


-- 


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libfortran/24305] Complex(10) formatted IO is broken.
  2005-10-11  5:50 [Bug libfortran/24305] New: Complex(10) formatted IO is broken jblomqvi at cc dot hut dot fi
  2005-10-11  5:55 ` [Bug libfortran/24305] " jblomqvi at cc dot hut dot fi
@ 2005-11-05 18:08 ` jblomqvi at cc dot hut dot fi
  2005-11-06 18:28 ` jb at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jblomqvi at cc dot hut dot fi @ 2005-11-05 18:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jblomqvi at cc dot hut dot fi  2005-11-05 18:08 -------
Patch (that also fixes PR 24174) here:
http://gcc.gnu.org/ml/gcc-patches/2005-11/msg00348.html


-- 


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libfortran/24305] Complex(10) formatted IO is broken.
  2005-10-11  5:50 [Bug libfortran/24305] New: Complex(10) formatted IO is broken jblomqvi at cc dot hut dot fi
  2005-10-11  5:55 ` [Bug libfortran/24305] " jblomqvi at cc dot hut dot fi
  2005-11-05 18:08 ` jblomqvi at cc dot hut dot fi
@ 2005-11-06 18:28 ` jb at gcc dot gnu dot org
  2005-11-11 20:41 ` jb at gcc dot gnu dot org
  2005-11-13  6:31 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: jb at gcc dot gnu dot org @ 2005-11-06 18:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jb at gcc dot gnu dot org  2005-11-06 18:28 -------
Subject: Bug 24305

Author: jb
Date: Sun Nov  6 18:28:22 2005
New Revision: 106563

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106563
Log:
gfortran ChangeLog

2005-11-06  Janne Blomqvist <jb@gcc.gnu.org>

        PR fortran/24174
        PR fortran/24305
        * fortran/trans-io.c (gfc_build_io_library_fndecls): Add kind
        argument to transfer_array.
        (transfer_array_desc): Add kind argument.

testsuite ChangeLog:

2005-11-06  Janne Blomqvist <jb@gcc.gnu.org>

        PR fortran/24174
        PR fortran/24305
        * testsuite/gfortran.dg/large_real_kind_form_io_1.f90: New file.

libgfortran Changelog:

2005-11-06  Janne Blomqvist <jb@gcc.gnu.org>

        PR fortran/24174
        PR fortran/24305
        * io/io.h: Add argument to prototypes, add prototypes for
        size_from_*_kind functions.
        * io/list_read.c (read_complex): Add size argument, use
        it. 
        (list_formatted_read): Add size argument, cleanup.
        (list_formatted_read_scalar): Add size argument.
        (nml_read_obj): Fix for padding.
        * io/transfer.c: Add argument to transfer function pointer.
        (unformatted_read): Add size argument.
        (unformatted_write): Likewise.
        (formatted_transfer_scalar): Fix for padding with complex(10).
        (formatted_transfer): Add size argument, cleanup.
        (transfer_integer): Add size argument to transfer call.
        (transfer_real): Likewise.
        (transfer_logical): Likewise.
        (transfer_character): Likewise.
        (transfer_complex): Likewise.
        (transfer_array): New kind argument, use it.
        (data_transfer_init): Add size argument to formatted_transfer
        call.
        (iolength_transfer): Add size argument, cleanup.
        * io/write.c (write_complex): Add size argument, fix for padding
        with complex(10).
        (list_formatted_write): Add size argument, cleanup.
        (list_formatted_write_scalar): Add size argument, use it.
        (nml_write_obj): Fix for size vs. kind issue.
        * io/size_from_kind.c: New file.
        * Makefile.am: Add io/size_from_kind.c.
        * configure: Regenerate.
        * Makefile.in: Regenerate.


Added:
    trunk/gcc/testsuite/gfortran.dg/large_real_kind_form_io_1.f90
    trunk/libgfortran/io/size_from_kind.c
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-io.c
    trunk/gcc/testsuite/ChangeLog
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/Makefile.am
    trunk/libgfortran/Makefile.in
    trunk/libgfortran/configure
    trunk/libgfortran/io/io.h
    trunk/libgfortran/io/list_read.c
    trunk/libgfortran/io/transfer.c
    trunk/libgfortran/io/write.c


-- 


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libfortran/24305] Complex(10) formatted IO is broken.
  2005-10-11  5:50 [Bug libfortran/24305] New: Complex(10) formatted IO is broken jblomqvi at cc dot hut dot fi
                   ` (2 preceding siblings ...)
  2005-11-06 18:28 ` jb at gcc dot gnu dot org
@ 2005-11-11 20:41 ` jb at gcc dot gnu dot org
  2005-11-13  6:31 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: jb at gcc dot gnu dot org @ 2005-11-11 20:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jb at gcc dot gnu dot org  2005-11-11 20:41 -------
The recent patch on 2005-11-06 AFAICS fixes this bug.


-- 

jb at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libfortran/24305] Complex(10) formatted IO is broken.
  2005-10-11  5:50 [Bug libfortran/24305] New: Complex(10) formatted IO is broken jblomqvi at cc dot hut dot fi
                   ` (3 preceding siblings ...)
  2005-11-11 20:41 ` jb at gcc dot gnu dot org
@ 2005-11-13  6:31 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-13  6:31 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.1.0


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-11-13  6:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-11  5:50 [Bug libfortran/24305] New: Complex(10) formatted IO is broken jblomqvi at cc dot hut dot fi
2005-10-11  5:55 ` [Bug libfortran/24305] " jblomqvi at cc dot hut dot fi
2005-11-05 18:08 ` jblomqvi at cc dot hut dot fi
2005-11-06 18:28 ` jb at gcc dot gnu dot org
2005-11-11 20:41 ` jb at gcc dot gnu dot org
2005-11-13  6:31 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).