$ cat foo3.f90 program main i = -1 print '(Z8)',i end program main $ gfortran foo3.f90 $ ./a.out ******** $ gfortran -v Using built-in specs. Target: ia64-unknown-linux-gnu Configured with: ../gcc-4.1-20050625/configure --prefix=/home/zfkts --enable- languages=c,f95 Thread model: posix gcc version 4.1.0 20050625 (experimental) The output should be FFFFFFFF
Confirmed. This bug is due to my recent patch to support large integer kinds. I'm thinking about how we should fix this.
It's probably easiest to have xtoa() and friends extract the integer for themselves. If you do this, don't forget to increase the size of buffer[] so it can hold largest_integer_kind*8+1 characters for binary representation. Would it be possible to define a macro GFC_LARGEST_INTEGER_KIND in kinds.h?
For the GFC_LARGEST_INTEGER_KIND macro, there is already a GFC_INTEGER_LARGEST. Or do you mean that GFC_LARGEST_INTEGER_KIND should be just 8 (or 16), not GFC_INTEGER_8 (or GFC_INTEGER_16)? As for this bug, the solution you mention was the one I thought of, but it means changing prototypes. A better solution (at least, I think it is better) is to have an extract_uint() function that does cast to GFC_UINTEGER_4 before casting to GFC_UINTEGER_LARGEST. Attached patch fixes the problem (for Z, O and B edit descriptors, with all kinds). I'm leaving town tomorrow, won't have access to an internet connection and lots of things to do before tomorrow. So, please feel free to test and commit this patch! If nobody does it, I'll do it when I come back (in August).
Created attachment 9205 [details] Patch
Subject: Bug 22217 CVSROOT: /cvs/gcc Module name: gcc Changes by: tkoenig@gcc.gnu.org 2005-07-09 09:33:32 Modified files: libgfortran : ChangeLog libgfortran/io : write.c libgfortran/runtime: error.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/gfortran.dg: negative-z-descriptor.f90 Log message: 2005-07-07 Francois-Xavier Coudert <coudert@clipper.ens.fr> Thomas Koenig <Thomas.Koenig@online.de> PR libfortran/22217 * io/write.c (extract_unit): New function; extract ints as unsigned signed int of the correct size. * io/write.c (write_int): Use it. * runtime/error.c: Adjust copyright years. Adjust size of buffer to maximum that can occur. 2005-07-07 Thomas Koenig <Thomas.Koenig@online.de> PR libfortran/22217 * gfortran.dg/negative-z-descriptor.f90: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/ChangeLog.diff?cvsroot=gcc&r1=1.258&r2=1.259 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/write.c.diff?cvsroot=gcc&r1=1.39&r2=1.40 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/runtime/error.c.diff?cvsroot=gcc&r1=1.10&r2=1.11 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5745&r2=1.5746 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/negative-z-descriptor.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1
No need to apply on 4.0 branch, since support for large kinds is only in mainline. Fixed.