- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
With 12.0.4 (and earlier) I'm getting some unexpected errors about user-defined type-bound operators.
This is a follow on from a post on c.l.f recently (http://coding.derkeiler.com/Archive/Fortran/comp.lang.fortran/2011-05/msg00504.html) where I was blundering around trying to understand how these generics could be used. The code in that post shows some very wishful but erroneous thinking on my part and also the compiler failing to pick up on ambiguous interfaces for the generic.
[fortran]MODULE GenericUnaryOperatorModule IMPLICIT NONE TYPE, ABSTRACT :: Parent CHARACTER(:), ALLOCATABLE :: some_text CONTAINS PROCEDURE(parent_UnaryOp_abstract), DEFERRED :: UnaryOp GENERIC :: OPERATOR(.UnaryOp.) => UnaryOp END TYPE Parent ABSTRACT INTERFACE FUNCTION parent_UnaryOp_abstract(lhs) RESULT(res) IMPORT Parent IMPLICIT NONE CLASS(Parent), INTENT(IN) :: lhs CLASS(Parent), ALLOCATABLE :: res END FUNCTION parent_UnaryOp_abstract END INTERFACE TYPE, EXTENDS(Parent) :: Extension CONTAINS PROCEDURE :: UnaryOp => ext_UnaryOp END TYPE Extension CONTAINS FUNCTION ext_UnaryOp(lhs) RESULT(res) CLASS(Extension), INTENT(IN) :: lhs CLASS(Parent), ALLOCATABLE:: res !**** ALLOCATE(res, SOURCE=Extension('ext_UnaryOp')) END FUNCTION ext_UnaryOp SUBROUTINE dump(arg) CLASS(Parent), INTENT(IN) :: arg PRINT "(A)", arg%some_text END SUBROUTINE dump END MODULE GenericUnaryOperatorModule PROGRAM GenericUnaryOperator USE GenericUnaryOperatorModule IMPLICIT NONE CLASS(Parent), ALLOCATABLE :: a TYPE(Extension) :: b !**** ALLOCATE(Extension:: a) CALL dump(.UnaryOp. a) ! Unexpected error #6764? CALL dump(.UnaryOp. b) ! #1 END PROGRAM GenericUnaryOperator [/fortran]If you comment out #1 above to allow compilation to succeed you'll get a link time reference to the abstract interface (I think that's already reported?).
This is a follow on from a post on c.l.f recently (http://coding.derkeiler.com/Archive/Fortran/comp.lang.fortran/2011-05/msg00504.html) where I was blundering around trying to understand how these generics could be used. The code in that post shows some very wishful but erroneous thinking on my part and also the compiler failing to pick up on ambiguous interfaces for the generic.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks - I have escalated this issue as DPD200169597.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A fix for this has been found and will be in a release later this year. Sorry for the delay.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page