From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9318 invoked by alias); 15 Aug 2010 16:44:36 -0000 Received: (qmail 9172 invoked by uid 48); 15 Aug 2010 16:44:23 -0000 Date: Sun, 15 Aug 2010 16:44:00 -0000 Subject: [Bug fortran/45288] New: Double initialization: Warn if the value is different X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "burnus at gcc dot gnu dot org" 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: 2010-08/txt/msg01211.txt.bz2 The following program (pasted in the #fortran IRC channel) is accepted by gfortran -- unless -std=f2008 is used. Expected: By default a warning (or error) is printed - if two different values are used. Maybe one should reject the program altogether - or allow it only with -std=legacy. -- The program can too easily produce indented results (cf. below). However, I think one can still allow double initialization of the same value with -std=gnu and without a warning. Without a warning (or better error) one can easily miss unintended double initializations - e.g. in legacy programs. Additionally, the result of such an initialization by different values is completely arbitrary as the program below shows. As variant, one can swap the whole-array initialization ("prefill") with the "individual values". ifort always prints "-1" independent of the order, Pathscale seemingly does what the user intended - the initially set "-1" is later overridden. While gfortran keeps the initial value, i.e. prints "-1" for the program below but the "intended" result if one swaps the order. PROGRAM Foo C COMMON Variables PARAMETER (MatDim=4) PARAMETER (MatMax=MatDim**2) DOUBLE PRECISION Matrix(MatDim,MatDim) COMMON /CNMatrix/ Matrix PRINT *,'Matrix:' PRINT '(4(4(F5.2,3H ),/))',Matrix END BLOCK DATA MatrixData C COMMON Variables PARAMETER (MatDim=4) PARAMETER (MatMax=MatDim**2) DOUBLE PRECISION Matrix(MatDim,MatDim) COMMON /CNMatrix/ Matrix DATA Matrix/MatMax*-1.0/ ! prefill DATA Matrix(2,1)/2.0/ ! individual values DATA Matrix(1,2)/3.0/ ! individual values END -- Summary: Double initialization: Warn if the value is different Product: gcc Version: 4.6.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: burnus at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45288