- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
i have a function which returns CLASS(*). Overall it is working fine except if the returned value is from type CHARACTER(*). Here is a minimal example:
MODULE test_mod CONTAINS FUNCTION test() RESULT(result) IMPLICIT NONE CLASS(*), POINTER :: result ALLOCATE(result, source='test') END FUNCTION Test END MODULE test_mod !PROGRAM class_void_bug_not_working ! USE test_mod ! IMPLICIT NONE ! ! ! no need to declare pointer! ! SELECT TYPE (pointer => test()) ! TYPE IS (CHARACTER(*)) ! WRITE(*,*) pointer ! END SELECT !END PROGRAM PROGRAM class_void_bug_working IMPLICIT NONE CLASS(*), ALLOCATABLE :: result ALLOCATE(result, source='test') ! still no need for pointer to be declared SELECT TYPE (pointer => result) TYPE IS (CHARACTER(*)) WRITE(*,*) pointer END SELECT END PROGRAM !PROGRAM class_void_bug_working_with_function ! USE test_mod ! IMPLICIT NONE ! ! ! now pointer has to be declared ! CLASS(*), POINTER :: pointer ! ! pointer => test() ! ! SELECT TYPE (pointer) ! TYPE IS (CHARACTER(*)) ! WRITE(*,*) pointer ! END SELECT !END PROGRAM
I was able to compile a working version, but there are still a few things I do not understand (see source code)
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In the first case, "pointer" is the associate-name, which becomes declared with the type and (many of the) attributes of the selector ("result"). In the second case, "pointer" is both the associate-name and the selector - this requires the selector to be a named variable and hence declared (since you have IMPLICIT NONE).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thank you so far.
What about the compiling but not working Program:
PROGRAM class_void_bug_not_working USE test_mod IMPLICIT NONE SELECT TYPE (pointer => test()) TYPE IS (CHARACTER(*)) WRITE(*,*) pointer END SELECT END PROGRAM
If the function test() is giving a real or an integer back the example prints correct to cmd, only if it is a character it is not working-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Julian H. wrote:
thank you so far.
What about the compiling but not working Program .. only if it is a character it is not working-
I think it's compiler bug in Intel Fortran compiler 18.0 Update 3 and perhaps earlier versions also.
However the issue appears to have been fixed in 19.0 Beta Update 1.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So I guess there is no need to file a bug report.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My advice is to always file a bug report, if for no other reason to add your test case to the regression test set.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page