Bug 46846 - Bogus warning: "Interface mismatch in dummy procedure .* has the wrong number of arguments" for intrinsic functions with optional arguments
Summary: Bogus warning: "Interface mismatch in dummy procedure .* has the wrong number...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic, documentation, wrong-code
Depends on:
Blocks:
 
Reported: 2010-12-08 09:05 UTC by Tobias Burnus
Modified: 2015-12-19 13:45 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-12-19 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2010-12-08 09:05:21 UTC
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/8ac296b9404b3245

lnblnk is a GNU extension.
char, ichar, int, and len_trim are also rejected by other compilers.

Currently, gfortran prints the warning

  Warning: Interface mismatch in dummy procedure 'fun' at (1): '%s' has
           the wrong number of arguments

for the intrinsics aint, anint, index, len and nint.

"13.6 Specific names for standard intrinsic functions"
Specic Name    Generic Name Argument    Type and Kind
AINT           AINT                     default real
ANINT          ANINT                    default real
INDEX          INDEX                    default character
LEN            LEN                      default character
NINT           NINT                     default real

The problem is that all those functions have an optional KIND= argument - which, however, is not included in the specific functions (as backward compatibility to Fortran 77). Thus, the warning is bogus - but another question is whether this can lead to wrong code by not passing NULL as second argument.


I have not checked, but maybe the documentation should also be improved (cf. James' posting to c.l.f)
Comment 2 Tobias Burnus 2010-12-08 19:47:50 UTC
Cf. also for REAL: http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/bc0e811575b758ab -- The documentation seems to be OK, but an ICE is shown at the very end (in gfc_typenode_for_spec).
Comment 3 Tobias Burnus 2010-12-09 08:05:31 UTC
Another post by James about REAL:
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/991e2a17662a3bde
Comment 4 Dominique d'Humieres 2015-12-19 13:45:03 UTC
This PR is a real mess.

> lnblnk is a GNU extension.
> char, ichar, int, and len_trim are also rejected by other compilers.

I think gfortran is correct when rejecting the intrinsic functions in

Table 13.3: Restricted specific intrinsic functions

(Fortran 2015 draft).

> The problem is that all those functions have an optional KIND= argument -
> which, however, is not included in the specific functions (as backward
> compatibility to Fortran 77). Thus, the warning is bogus - 

I agree and I have changed the summary.

> but another question is whether this can lead to wrong code by not passing
> NULL as second argument.

I did not find such wrong codes, however I have opened pr68433 for wrong codes when including the optional argument in the interfaces.

> I have not checked, but maybe the documentation should also be improved
> (cf. James' posting to c.l.f)

If so, I think it deserves a separate PR.