https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109394
Bug ID: 109394 Summary: list-directed read of character from complex number Product: gcc Version: og11 (devel/omp/gcc-11) Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: snavece at hotmail dot com Target Milestone: --- My question is how should a complex number be parsed when using a list-directed read to a string? Currently complex numbers are parsed to two tokens in gfortran. An alternative is to parse complex numbers to one token. See examples below. I recognize that it is a judgment call. I would argue the second technique makes the handling of complex numbers easier, although it may raise a number of unintended consequences that I have not considered. Using the following file, test.f: PROGRAM MAIN C IMPLICIT NONE C INTEGER, PARAMETER :: MXTOKS = 10 INTEGER IERR C CHARACTER * 20 TOKENS(MXTOKS) CHARACTER * 132 LINE C LINE = '''A B C'' "A B C" (1.0, 2.0) 1 2 3 1.0 2.0 3.0' print *, 'Line: /', TRIM(LINE), '/' READ (LINE, *, IOSTAT=IERR) TOKENS print *, TOKENS print *, 'Ierr:', IERR STOP END and the commands in a Cygwin mksh shell: $ gfortarn -o test.exe test.f $ ./test.exe The result is: Line: /'A B C' "A B C" (1.0, 2.0) 1 2 3 1.0 2.0 3.0/ A B C A B C (1.0 2.0) 1 2 3 1.0 2.0 3.0 Ierr: 0 An alternate parsing could be: 'A B C' "A B C" (1.0, 2.0) 1 2 3 1.0 2.0 3.0 Ierr: -1 The IERR = -1 indicating that end of line was encountered before reading 10 tokens. My environment is mksh in a Cygwin 64 delivery running on Windows 10 Version 12H2 (OS Build 19044.2728) $ gfortran -v Using built-in specs. COLLECT_GCC=gfortran COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/11/lto-wrapper.exe Target: x86_64-pc-cygwin Configured with: /mnt/share/cygpkgs/gcc/gcc.x86_64/src/gcc-11.3.0/configure --srcdir=/mnt/share/cygpkgs/gcc/gcc.x86_64/src/gcc-11.3.0 --prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/gcc --htmldir=/usr/share/doc/gcc/html -C --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin --without-libiconv-prefix --without-libintl-prefix --libexecdir=/usr/lib --with-gcc-major-version-only --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --enable-bootstrap --enable-__cxa_atexit --with-dwarf2 --with-tune=generic --enable-languages=c,c++,fortran,lto,objc,obj-c++,jit --enable-graphite --enable-threads=posix --enable-libatomic --enable-libgomp --enable-libquadmath --enable-libquadmath-support --disable-libssp --enable-libada --disable-symvers --with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-isl --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=gcc4-compatible --enable-libstdcxx-filesystem-ts Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.3.0 (GCC)