The following program compiles OK with no message that st is being redefined. function fun() result(st) character(2) st character(1) st st = '1' end function fun
Confirmed with 4.2.3 and 4.3.2, with 4.4.0 (trunk) I get: [ibook-dhum] f90/bug% gfc -Wall pr37412.f90 pr37412.f90:3.17: character(1) st 1 Warning: Symbol 'st' at (1) already has basic type of CHARACTER Now I am not sure which statement is the winner. Is this defined somewhere?
(In reply to comment #1) > Warning: Symbol 'st' at (1) already has basic type of CHARACTER I think one should print here an error as the LEN type parameter is different. The same issue exists for the KIND type parameter. > Now I am not sure which statement is the winner. Is this defined somewhere? I think it is a bug (cf. above) and thus not really defined. However, testing with gfortran 4.3 implies that the latter definition wins.
With -std=f95 all the gfortran versions I have reject the code with: [ibook-dhum] f90/bug% gfc -std=f95 pr37412.f90 pr37412.f90:3.17: character(1) st 1 Error: Symbol 'st' at (1) already has basic type of CHARACTER > I think one should print here an error as the LEN type parameter is different. > > The same issue exists for the KIND type parameter. I agree this would avoid to wonder which statement is taken into account.
IIRC, this behaviour is due to a patch I submitted some time ago. Maybe I could change this warning into an error even for non-standard conforming mode in case the length or a kind parameter differs. What do you think?
*** Bug 34527 has been marked as a duplicate of this bug. ***
(In reply to comment #4) > Maybe I could change this warning into an error even for non-standard > conforming mode in case the length or a kind parameter differs. What > do you think? I assume, this happened at some point. Current 4.5.0 20091208 gives: $> gfortran-svn pr37412.f90 pr37412.f90:3.17: character(1) st 1 Error: Symbol 'st' at (1) already has basic type of CHARACTER I believe this is correct. Closing.