https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64138
--- Comment #6 from Steve Kargl <sgk at troutmask dot apl.washington.edu> --- On Tue, Dec 02, 2014 at 03:37:19PM +0000, wong.david-c at epa dot gov wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64138 > > What is your fix? > I meant I fixed the code you posted. It was missing a CONTAINS statement before c_sub_cc, and there is an extra 'j' on the end of one of the 'end function c_sub_??' lines. > In the original code, c_sub_cr and c_sub_rc are distinct because the > sequence of argument type are different. Other compilers have no problem to > distinguish them. Please advise. You can get the code to compile if you change the dummy argument names in c_sub_cr and c_sub_rc to unique entities. For example, (and yes I changed the function and variable names while debugging) type(complex_number) function f2(z1, num) type (complex_number), intent(in) :: z1 real(kind=dp), intent(in) :: num f2%re = z1%re - num f2%im = z1%im end function f2 type(complex_number) function f3(num, z2) type (complex_number), intent(in) :: z2 real(kind=dp), intent(in) :: num f3%re = num - z2%re f3%im = - z2%im end function f3 The only problem with this workaround is that you cannot use keyword argument association. For example, type(complex_number) :: z=complex_number(1.,2.) real x = 3. z = c_sub(num=x, z) The above is ambiguous because the reduced argument list for f2 and f3 are identical, so the generic c_sub can be mapped to either. Fortunately, gfortran tries to help in this situation % gfortran -o z -fmax-errors=1 a.f90 a.f90:53.18: b = c_sub(num=x, a); print '(A,2F5.1)', '(x-a)? = ', b%re, b%im 1 Error: Missing keyword name in actual argument list at (1) Fatal Error: Error count reached limit of 1. Note, however, AFAIK, a keyword is not necessary and is not required. IHMO, issuing this error message could in fact be considered a bug. In fact, if you change the order of arguments to b = c_sub(a, num=x); print '(A,2F5.1)', '(x-a)? = ', b%re, b%im This will compile without error. If the former line producing an error about a missing keyword shouldn't the latter?