public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "kargl at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/64138] gfortran interface issue
Date: Mon, 01 Dec 2014 20:17:00 -0000	[thread overview]
Message-ID: <bug-64138-4-OVZCgxuAwv@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-64138-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64138

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2014-12-01
     Ever confirmed|0                           |1

--- Comment #4 from kargl at gcc dot gnu.org ---
(In reply to kargl from comment #1)
> (In reply to david from comment #0)
> > Hi,
> > 
> >    I have created a complex number module:
> > 
> >        module complex_number_module
> >         implicit none
> > 
> >         integer, parameter :: loc_real_precision = 8
> > 
> >         type complex_number
> >           real(kind=loc_real_precision) :: real_part, imag_part
> >         end type complex_number
> > 
> >         interface c_sub
> >           module procedure c_sub_cc,    &      ! z1 - z2
> >                            c_sub_cr,    &      ! z1 - num, where num is a
> > real number
> >                            c_sub_rc            ! num - z1, where num is a
> > real number
> >         end interface
> > 
> > ! --------------------------------------------------------------------------
> >         type (complex_number) function c_sub_cc (z1, z2)
> > 
> >         type (complex_number), intent(in) :: z1, z2
> > 
> >         c_sub_cc%real_part = z1%real_part - z2%real_part
> >         c_sub_cc%imag_part = z1%imag_part - z2%imag_part
> > 
> >         end function c_sub_ccj
> > 
> > ! --------------------------------------------------------------------------
> >         type (complex_number) function c_sub_cr (z1, num)
> > 
> >         type (complex_number),     intent(in) :: z1
> >         real(kind=loc_real_precision), intent(in) :: num
> > 
> >         c_sub_cr%real_part = z1%real_part - num
> >         c_sub_cr%imag_part = z1%imag_part
> > 
> >         end function c_sub_cr
> > 
> > ! --------------------------------------------------------------------------
> >         type (complex_number) function c_sub_rc (num, z1)
> > 
> >         type (complex_number),     intent(in) :: z1
> >         real(kind=loc_real_precision), intent(in) :: num
> > 
> >         c_sub_rc%real_part = num - z1%real_part
> >         c_sub_rc%imag_part = - z1%imag_part
> > 
> >         end function c_sub_rc
> > 
> >       end module complex_number_module
> > 
> > When I compile with gfortran (version 4.6.4), I got the following error:
> > 
> > module_twoway_rrtmg_aero_optical_util.F:14.85:
> > 
> >                  c_sub_rc            ! num - z1, where num is a real number
> >                                                                            1
> > 
> > Error: Ambiguous interfaces 'c_sub_rc' and 'c_sub_cr' in generic interface
> > 'c_sub' at (1)
> > 
> > I don't see any ambiguity and I don't encounter any problem with other
> > compilers such pgi and ifort. Please advise.
> > 
> > Cheers,
> > David
> 
> Please attach the exact code you tried to compile.  The above is nonsense.

I fixed the above code.  I believe gfortran is correct to complain
about an ambiguous interface.  In the last two line below, which
of c_sub_rc and c_sub_cr should be called.

program foo
  use complex_number_module
  type(complex_number) a, b
  real(dp) x
  a%re = 1
  a%im = 2
  x = 1
  b = c_sub(a, x); print '(A,2F5.1)', 'a-x = ', b%re, b%im
  b = c_sub(x, a); print '(A,2F5.1)', 'x-a = ', b%re, b%im
  b = c_sub(z1=a, num=x); print '(A,2F5.1)', 'a-x = ', b%re, b%im
  b = c_sub(num=x,a); print '(A,2F5.1)', 'a-x = ', b%re, b%im
end program foo


  parent reply	other threads:[~2014-12-01 20:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-01 15:03 [Bug fortran/64138] New: " wong.david-c at epa dot gov
2014-12-01 17:24 ` [Bug fortran/64138] " kargl at gcc dot gnu.org
2014-12-01 20:11 ` wong.david-c at epa dot gov
2014-12-01 20:13 ` wong.david-c at epa dot gov
2014-12-01 20:17 ` kargl at gcc dot gnu.org [this message]
2014-12-02 15:37 ` wong.david-c at epa dot gov
2014-12-02 16:05 ` sgk at troutmask dot apl.washington.edu
2014-12-02 17:13 ` dominiq at lps dot ens.fr
2014-12-02 17:29 ` sgk at troutmask dot apl.washington.edu
2014-12-02 17:36 ` dominiq at lps dot ens.fr
2014-12-06 15:03 ` dominiq at lps dot ens.fr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-64138-4-OVZCgxuAwv@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).