Bug 86297 - rejects valid code on type extension
Summary: rejects valid code on type extension
Status: RESOLVED DUPLICATE of bug 47805
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 9.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-06-25 04:43 UTC by Jürgen Reuter
Modified: 2018-06-25 09:39 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jürgen Reuter 2018-06-25 04:43:47 UTC
The following code is rejected my gfortran 9.0 (I also checked 5.4.0). It is accepted by nagfor 6.2 and ifort 18 and 19beta, but was rejected by ifort 17 with the same argument as by gfortran. It is rejected by PGI fortran v18.5. Apparently, it is from an interp F08/0052 in F2008 corrigendum one and was discussed by Ian Harvey on c.l.f. on July 5, 2016 under the topic "Interpretation F08/0052 (overriding private bindings) ". Somehow, ifort changed their minds to accept this code, so it is standard-compliant? 


MODULE example1_m1
  TYPE t1
   CONTAINS
     PROCEDURE,PRIVATE,NOPASS :: p ! (1).
  END TYPE t1
CONTAINS
  SUBROUTINE p
    PRINT *,'p'
  END SUBROUTINE p
  SUBROUTINE do_p(x)
    CLASS(t1) x
    CALL x%p
  END SUBROUTINE do_p
END MODULE example1_m1
MODULE example1_m2
  USE example1_m1
  TYPE,EXTENDS(t1) :: t2
   CONTAINS
     PROCEDURE,NOPASS :: p => p2 ! (2).
  END TYPE t2
CONTAINS
  SUBROUTINE p2(n)
    PRINT *,'p2',n
  END SUBROUTINE p2
END MODULE example1_m2
~
Comment 1 Jürgen Reuter 2018-06-25 04:44:18 UTC
This is the error message from gfortran:
Error: 'p' at (1) must have the same number of formal arguments as the overridden procedure
Comment 2 Dominique d'Humieres 2018-06-25 09:37:10 UTC
Duplicate of pr47805. This has been discussed at

https://groups.google.com/forum/#!topic/comp.lang.fortran/16Rane73lRI

*** This bug has been marked as a duplicate of bug 47805 ***
Comment 3 Jürgen Reuter 2018-06-25 09:39:04 UTC
Sorry, I should have scanned a little better for existing PRs.