Bug 34527

Summary: Declaring a variable twice with different characteristics
Product: gcc Reporter: Tobias Burnus <burnus>
Component: fortranAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: normal CC: burnus, d, dfranke, gcc-bugs
Priority: P3 Keywords: accepts-invalid
Version: 4.3.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2008-03-13 14:30:01

Description Tobias Burnus 2007-12-19 00:01:56 UTC
The following is invalid and rejected using -std=f2003, but I wonder whether one should not also reject it otherwise? What is the string length?

function a(n,m)
   integer :: n,m
   character(n) a
   character(m) a
end

ifort and g95 reject it always.

 * * *

If one wants to add only a check whether the variables are the same, one could use the same check for:

function a(n,m)
   integer :: n,m
   character(n) a
   character(m) b
entry b(n,m)
end

NAG f95 and ifort reject this with:
- Incompatible character length for ENTRY B of function A
- The characteristics of the function named on the ENTRY statement are different from the characteristics of the result of the function named on the FUNCTION statement.

gfortran currently (PR34421) accepts this for non-constant expressions.
Comment 1 Daniel Franke 2009-12-08 20:58:30 UTC
Marking as dupe, discussion happened in PR37412.

*** This bug has been marked as a duplicate of 37412 ***