public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/40443]  New: Elemental procedure in genericl interface incorrectly selected in preference to specific procedure
@ 2009-06-15  1:16 ian_harvey at bigpond dot com
  2009-06-15  7:46 ` [Bug fortran/40443] " burnus at gcc dot gnu dot org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: ian_harvey at bigpond dot com @ 2009-06-15  1:16 UTC (permalink / raw)
  To: gcc-bugs

F95 standard section 14.1.2.4.1 (particular Note 14.6) implies to me that when
an elemental and a non-elemental specific procedure in a generic interface both
"match" a reference, it is the specific instance that should be selected.

The reference selected by gfortran appears to depend on the ordering of
procedures in the generic interface block.  I'd expect the last line of output
from the following to be "S, S" as a result of selecting the specific procedure
"SpecProc".  I get "E, E" which has come from the elemental procedure.


MODULE SomeOptions
  IMPLICIT NONE  
  INTERFACE ElemSpec
    MODULE PROCEDURE ElemProc
    MODULE PROCEDURE SpecProc
  END INTERFACE ElemSpec  
  INTERFACE SpecElem
    MODULE PROCEDURE SpecProc
    MODULE PROCEDURE ElemProc
  END INTERFACE SpecElem
CONTAINS
  ELEMENTAL SUBROUTINE ElemProc(a)  
    CHARACTER, INTENT(OUT) :: a
    !****
    a = 'E'            
  END SUBROUTINE ElemProc

  SUBROUTINE SpecProc(a)  
    CHARACTER, INTENT(OUT) :: a(:)
    !****    
    a = 'S'    
  END SUBROUTINE SpecProc
END MODULE SomeOptions

PROGRAM MakeAChoice
  USE SomeOptions  
  IMPLICIT NONE
  CHARACTER scalar, array(2)    
  !****
  CALL ElemSpec(scalar) ! Should choose the elemental (and does)
  WRITE (*, 100) scalar
  CALL ElemSpec(array)  ! Should choose the specific (and does)
  WRITE (*, 100) array
  !----
  CALL SpecElem(scalar) ! Should choose the elemental (and does)
  WRITE (*, 100) scalar
  CALL SpecElem(array)  ! Should choose the specific (but doesn't)
  WRITE (*, 100) array  
  !----
  100 FORMAT(A,:,', ',A)
END PROGRAM MakeAChoice


>gfortran --version
GNU Fortran (GCC) 4.5.0 20090421 (experimental) [trunk revision 146519]


-- 
           Summary: Elemental procedure in genericl interface incorrectly
                    selected in preference to specific procedure
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ian_harvey at bigpond dot com
 GCC build triplet: i586-pc-mingw32
  GCC host triplet: i586-pc-mingw32
GCC target triplet: i586-pc-mingw32


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40443


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/40443] Elemental procedure in genericl interface incorrectly selected in preference to specific procedure
  2009-06-15  1:16 [Bug fortran/40443] New: Elemental procedure in genericl interface incorrectly selected in preference to specific procedure ian_harvey at bigpond dot com
@ 2009-06-15  7:46 ` burnus at gcc dot gnu dot org
  2009-06-15  8:28 ` jpr at csc dot fi
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-06-15  7:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from burnus at gcc dot gnu dot org  2009-06-15 07:46 -------
Paul, I CC you as you are our generic-resolution expert.

 * * *

gfortran 4.1 to 4.5, NAG f95 5.1, g95, ifort 11, openf95, Sun Studio 12 all
print the following:

E
S, S
E
E, E   ! << you expect an "S, S" here

Looking at the following excerpt from Fortran 2003, it looks indeed as if all
the compiler get it wrong. Especially, the standard does not assume (to my
reading) that the generic resolution depends on the order. However, before
changing it, one needs to double check - that several compiler gets it wrong
and (of my collection) none gets it correct also happens only rarely.

 * * *

"12.4.4.1 Resolving procedure references to names established to be generic

"(1) If the reference is consistent with a nonelemental reference to one of the
specific interfaces of a generic interface that has that name and either is in
the scoping unit in which the reference appears or is made accessible by a USE
statement in the scoping unit, the reference is to the specific procedure in
the interface block that provides that interface. The rules in 16.2.3 ensure
that there can be at most one such specific procedure.

 (2) If (1) does not apply, if the reference is consistent with an elemental
reference to one of the specific interfaces of a generic interface that has
that name and either is in the scoping unit in which the reference appears or
is made accessible by a USE statement in the scoping unit, the reference is to
the specific elemental procedure in the interface block that provides that
interface. The rules in 16.2.3 ensure that there can be at most one such
specific elemental procedure."


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pault at gcc dot gnu dot
                   |                            |org, burnus at gcc dot gnu
                   |                            |dot org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
  GCC build triplet|i586-pc-mingw32             |
   GCC host triplet|i586-pc-mingw32             |
 GCC target triplet|i586-pc-mingw32             |
           Keywords|                            |wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2009-06-15 07:46:13
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40443


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/40443] Elemental procedure in genericl interface incorrectly selected in preference to specific procedure
  2009-06-15  1:16 [Bug fortran/40443] New: Elemental procedure in genericl interface incorrectly selected in preference to specific procedure ian_harvey at bigpond dot com
  2009-06-15  7:46 ` [Bug fortran/40443] " burnus at gcc dot gnu dot org
@ 2009-06-15  8:28 ` jpr at csc dot fi
  2009-06-15 11:24 ` burnus at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jpr at csc dot fi @ 2009-06-15  8:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jpr at csc dot fi  2009-06-15 08:28 -------
(In reply to comment #1)
> Paul, I CC you as you are our generic-resolution expert.
> 
>  * * *
> 
> gfortran 4.1 to 4.5, NAG f95 5.1, g95, ifort 11, openf95, Sun Studio 12 all
> print the following:
> 
> E
> S, S
> E
> E, E   ! << you expect an "S, S" here
> 

FWIW, Portland and Intel compilers both print 

E
S, S
E
S, S

BR, Juha


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40443


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/40443] Elemental procedure in genericl interface incorrectly selected in preference to specific procedure
  2009-06-15  1:16 [Bug fortran/40443] New: Elemental procedure in genericl interface incorrectly selected in preference to specific procedure ian_harvey at bigpond dot com
  2009-06-15  7:46 ` [Bug fortran/40443] " burnus at gcc dot gnu dot org
  2009-06-15  8:28 ` jpr at csc dot fi
@ 2009-06-15 11:24 ` burnus at gcc dot gnu dot org
  2009-06-15 13:21 ` pault at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-06-15 11:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from burnus at gcc dot gnu dot org  2009-06-15 11:24 -------
> > gfortran 4.1 to 4.5, NAG f95 5.1, g95, ifort 11, openf95, Sun Studio 12 all
> > print the following:

Correction, ifort 9.1 to 11.1 all print "S, S" - sorry for missing it. But the
other compilers listed above indeed print "E, E".

> FWIW, Portland and Intel compilers both print 
> S, S


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2009-06-15 07:46:13         |2009-06-15 11:24:02
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40443


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/40443] Elemental procedure in genericl interface incorrectly selected in preference to specific procedure
  2009-06-15  1:16 [Bug fortran/40443] New: Elemental procedure in genericl interface incorrectly selected in preference to specific procedure ian_harvey at bigpond dot com
                   ` (2 preceding siblings ...)
  2009-06-15 11:24 ` burnus at gcc dot gnu dot org
@ 2009-06-15 13:21 ` pault at gcc dot gnu dot org
  2009-06-17 13:04 ` dominiq at lps dot ens dot fr
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-06-15 13:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pault at gcc dot gnu dot org  2009-06-15 13:21 -------
(In reply to comment #1)
> Paul, I CC you as you are our generic-resolution expert.

Well, gosh golly, that's a mantle that I did not seek:-)

Note that my account at the CC address is no longer valid - I'll fix that.

In the mean time I will peruse the standard.

Cheers

Paul


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40443


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/40443] Elemental procedure in genericl interface incorrectly selected in preference to specific procedure
  2009-06-15  1:16 [Bug fortran/40443] New: Elemental procedure in genericl interface incorrectly selected in preference to specific procedure ian_harvey at bigpond dot com
                   ` (3 preceding siblings ...)
  2009-06-15 13:21 ` pault at gcc dot gnu dot org
@ 2009-06-17 13:04 ` dominiq at lps dot ens dot fr
  2009-06-21  7:42 ` pault at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: dominiq at lps dot ens dot fr @ 2009-06-17 13:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from dominiq at lps dot ens dot fr  2009-06-17 13:04 -------
Note that the latest release of g95 gives now:

E
S, S
E
S, S


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40443


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/40443] Elemental procedure in genericl interface incorrectly selected in preference to specific procedure
  2009-06-15  1:16 [Bug fortran/40443] New: Elemental procedure in genericl interface incorrectly selected in preference to specific procedure ian_harvey at bigpond dot com
                   ` (4 preceding siblings ...)
  2009-06-17 13:04 ` dominiq at lps dot ens dot fr
@ 2009-06-21  7:42 ` pault at gcc dot gnu dot org
  2009-06-22  4:41 ` pault at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-06-21  7:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pault at gcc dot gnu dot org  2009-06-21 07:42 -------
This should be relatively easy to fix - I have not looked yet but I am rather
sure I know what to do and where to do it.

Cheers

Paul


-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pault at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2009-06-15 11:24:02         |2009-06-21 07:42:05
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40443


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/40443] Elemental procedure in genericl interface incorrectly selected in preference to specific procedure
  2009-06-15  1:16 [Bug fortran/40443] New: Elemental procedure in genericl interface incorrectly selected in preference to specific procedure ian_harvey at bigpond dot com
                   ` (5 preceding siblings ...)
  2009-06-21  7:42 ` pault at gcc dot gnu dot org
@ 2009-06-22  4:41 ` pault at gcc dot gnu dot org
  2009-06-22  4:42 ` pault at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-06-22  4:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pault at gcc dot gnu dot org  2009-06-22 04:41 -------
Subject: Bug 40443

Author: pault
Date: Mon Jun 22 04:41:10 2009
New Revision: 148776

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=148776
Log:
2009-06-22  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/40443
        * interface.c (gfc_search_interface): Hold back a match to an
        elementary procedure until all other possibilities are
        exhausted.

2009-06-22  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/40443
        * gfortran.dg/generic_18.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/generic_18.f90
Modified:
    trunk/gcc/fortran/interface.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40443


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/40443] Elemental procedure in genericl interface incorrectly selected in preference to specific procedure
  2009-06-15  1:16 [Bug fortran/40443] New: Elemental procedure in genericl interface incorrectly selected in preference to specific procedure ian_harvey at bigpond dot com
                   ` (6 preceding siblings ...)
  2009-06-22  4:41 ` pault at gcc dot gnu dot org
@ 2009-06-22  4:42 ` pault at gcc dot gnu dot org
  2009-06-29  7:49 ` burnus at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-06-22  4:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from pault at gcc dot gnu dot org  2009-06-22 04:42 -------
Subject: Bug 40443

Author: pault
Date: Mon Jun 22 04:41:53 2009
New Revision: 148777

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=148777
Log:
2009-06-22  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/40443
        * interface.c (gfc_search_interface): Hold back a match to an
        elementary procedure until all other possibilities are
        exhausted.

2009-06-22  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/40443
        * gfortran.dg/generic_18.f90: New test.

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40443


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/40443] Elemental procedure in genericl interface incorrectly selected in preference to specific procedure
  2009-06-15  1:16 [Bug fortran/40443] New: Elemental procedure in genericl interface incorrectly selected in preference to specific procedure ian_harvey at bigpond dot com
                   ` (7 preceding siblings ...)
  2009-06-22  4:42 ` pault at gcc dot gnu dot org
@ 2009-06-29  7:49 ` burnus at gcc dot gnu dot org
  2009-06-29  9:23 ` pault at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-06-29  7:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from burnus at gcc dot gnu dot org  2009-06-29 07:49 -------
Can this be backported to 4.4? If so, it should happen soonish to be in 4.4.1.
Paul, shall I do it for you?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40443


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/40443] Elemental procedure in genericl interface incorrectly selected in preference to specific procedure
  2009-06-15  1:16 [Bug fortran/40443] New: Elemental procedure in genericl interface incorrectly selected in preference to specific procedure ian_harvey at bigpond dot com
                   ` (8 preceding siblings ...)
  2009-06-29  7:49 ` burnus at gcc dot gnu dot org
@ 2009-06-29  9:23 ` pault at gcc dot gnu dot org
  2009-06-29 16:45 ` pault at gcc dot gnu dot org
  2009-06-29 16:46 ` pault at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-06-29  9:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from pault at gcc dot gnu dot org  2009-06-29 09:23 -------
(In reply to comment #9)
> Can this be backported to 4.4? If so, it should happen soonish to be in 4.4.1.
> Paul, shall I do it for you?
>

Thanks for the offer, Tobias - I'll be attending to it tonight.

Did you see that I have a fix for PR40551?

Cheers

Paul 


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40443


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/40443] Elemental procedure in genericl interface incorrectly selected in preference to specific procedure
  2009-06-15  1:16 [Bug fortran/40443] New: Elemental procedure in genericl interface incorrectly selected in preference to specific procedure ian_harvey at bigpond dot com
                   ` (9 preceding siblings ...)
  2009-06-29  9:23 ` pault at gcc dot gnu dot org
@ 2009-06-29 16:45 ` pault at gcc dot gnu dot org
  2009-06-29 16:46 ` pault at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-06-29 16:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from pault at gcc dot gnu dot org  2009-06-29 16:45 -------
Subject: Bug 40443

Author: pault
Date: Mon Jun 29 16:44:49 2009
New Revision: 149056

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=149056
Log:
2009-06-29  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/40443
        * interface.c (gfc_search_interface): Hold back a match to an
        elementary procedure until all other possibilities are
        exhausted.

2009-06-29  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/40443
        * gfortran.dg/generic_18.f90: New test.

Added:
    branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/generic_18.f90
Modified:
    branches/gcc-4_4-branch/gcc/fortran/ChangeLog
    branches/gcc-4_4-branch/gcc/fortran/interface.c
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40443


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/40443] Elemental procedure in genericl interface incorrectly selected in preference to specific procedure
  2009-06-15  1:16 [Bug fortran/40443] New: Elemental procedure in genericl interface incorrectly selected in preference to specific procedure ian_harvey at bigpond dot com
                   ` (10 preceding siblings ...)
  2009-06-29 16:45 ` pault at gcc dot gnu dot org
@ 2009-06-29 16:46 ` pault at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-06-29 16:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from pault at gcc dot gnu dot org  2009-06-29 16:46 -------
Fixed on trunk and 4.4

Thanks for the report

Paul


-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40443


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2009-06-29 16:46 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-15  1:16 [Bug fortran/40443] New: Elemental procedure in genericl interface incorrectly selected in preference to specific procedure ian_harvey at bigpond dot com
2009-06-15  7:46 ` [Bug fortran/40443] " burnus at gcc dot gnu dot org
2009-06-15  8:28 ` jpr at csc dot fi
2009-06-15 11:24 ` burnus at gcc dot gnu dot org
2009-06-15 13:21 ` pault at gcc dot gnu dot org
2009-06-17 13:04 ` dominiq at lps dot ens dot fr
2009-06-21  7:42 ` pault at gcc dot gnu dot org
2009-06-22  4:41 ` pault at gcc dot gnu dot org
2009-06-22  4:42 ` pault at gcc dot gnu dot org
2009-06-29  7:49 ` burnus at gcc dot gnu dot org
2009-06-29  9:23 ` pault at gcc dot gnu dot org
2009-06-29 16:45 ` pault at gcc dot gnu dot org
2009-06-29 16:46 ` pault at gcc dot gnu dot org

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).