using GNU Fortran 95 (GCC) 4.1.0 20051126 (prerelease) with '-g -pedantic -std=f95', I get a bad / no diagnostic for the following invalid code: INTEGER, PARAMETER :: C1=1 COMMON /C1/ I INTEGER I END
Well, only g95 sees this bug. Is it really a violation of the standard? I don't think so... ## g95 ## In file foo.f90:1 INTEGER, PARAMETER :: C1=1 1 Error: COMMON block 'c1' at (1) is also a PARAMETER ## Intel ## ## Portland ## ## Sun ##
I'm quite sure it's not, but it would be a first, if Joost were wrong. Is there anything special about parameters? Something like real x common /x/ y or even common /x/ x is perfectly valid.
Even Lahey's Fortran 90 and their 95 compiler does not error out about this. I wonder if xlf does.
(In reply to comment #3) > Even Lahey's Fortran 90 and their 95 compiler does not error out about this. > > I wonder if xlf does. > xlf90 -qsuffix=f=f90 mytest.f90 "mytest.f90", line 2.9: 1514-259 (S) A name must not be both the name of a named constant and the name of a COMMON block.
Confirmed then. I would expect for some reason that xlf is actually one of the better fortran compilers when it comes to rejecting invalid code.
I'm setting this to waiting until someone quotes something from the standard. Fortran has its quirks, but disallowing this special case would break the distintion between the names of commons and those of other named objects, which is otherwise maintained, so I'm sure this is valid code. But since being sure is not sufficient, I also checked the standard and I couldn't find anything disallowing this case.
See 14.1.2.1. A common block name in a scoping unit also may be the name of any local entity other than a named constant, intrinsic procedure, or a local variable that is also an external function in a function subprogram.
Thanks, Steve.
Subject: Bug number PR 25062 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-06/msg01932.html
Subject: Bug 25062 Author: burnus Date: Tue Jul 3 21:41:34 2007 New Revision: 126279 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=126279 Log: 2007-07-03 Tobias Burnus <burnus@net-b.de> PR fortran/25062 * resolve.c (resolve_common_blocks): New check function. (resolve_types): Use it. 2007-07-03 Tobias Burnus <burnus@net-b.de> PR fortran/25062 * common_7.f90: New. * common_8.f90: New. * common_9.f90: New. Added: trunk/gcc/testsuite/gfortran.dg/common_7.f90 trunk/gcc/testsuite/gfortran.dg/common_8.f90 trunk/gcc/testsuite/gfortran.dg/common_9.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/resolve.c trunk/gcc/testsuite/ChangeLog
Fixed. Note that the F95 standard is stricter than F2003. I added one -std=95 only check and two general checks. Still gfortran is too strict for F2003; see PR32515.
*** Bug 50072 has been marked as a duplicate of this bug. ***