From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11830 invoked by alias); 1 Oct 2008 21:01:20 -0000 Received: (qmail 11277 invoked by uid 48); 1 Oct 2008 20:59:57 -0000 Date: Wed, 01 Oct 2008 21:01:00 -0000 Subject: [Bug libfortran/37707] New: Namelist read of array of derived type incorrect X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "toon at moene dot indiv dot nluug dot nl" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2008-10/txt/msg00098.txt.bz2 The following program: type s integer m integer n end type s type(s) :: a(3) character*80 :: l = ' &namlis a%m=1,2, a%n=5,6, /' namelist /namlis/ a a%m=[87,88,89] a%n=[97,98,99] print*,a%m print*,a%n read(l,namlis) write(*,namlis) end prints: 87 88 89 97 98 99 At line 12 of file nl.f90 Fortran runtime error: Cannot match namelist object name 2 The error condition is bogus. According to the Fortran 2003 Standard, subclause 10.10.1.2 (third paragraph): "When the name in the input record represents an array variable or a variable of derived type, the effect is as if the variable represented where expanded into a sequence of scalar list items of intrinsic data types, in the same way that formatted input/output list items are expanded." In other words: a%m has to be read in in the same way as it has to be written out. That means that the original namelist read above should assign 1 to a(1)%m and 2 to a(2)%m and nothing (i.e., not change the value of a(3)%m) and, mutatis mutandis, for a(..)%n. -- Summary: Namelist read of array of derived type incorrect Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libfortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: toon at moene dot indiv dot nluug dot nl http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37707