- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
!================================================== ! ! Compile and run using: ! ifort optional-bug.f90 ! ./a.out !================================================== program option implicit none real, target :: at, dt real, pointer :: ap, dp at = 10; dt = 40 ap => at dp => dt dp => null() ! Uncommenting this line crashes print*, 'before ap, dp', ap, dp call mysub(ap, dp) print*, 'after ap, dp', ap, dp contains subroutine mysub(aa, dd) real :: aa real :: dd aa = 1000.*aa print*, ' Inside mysub aa = ', aa end subroutine mysub end program option
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think that you are not interpreting the program behavior correctly. It is not the passing of a null pointer (for an argument that is not referenced) that causes the SEGV, but the referencing of the target in the two I/O statements.
Remove ", dp" from the two PRINT statements, and you will see that the program runs with no SEGV happening.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much! We missed that one!
Let me try the original code I started with, which had to do with optional arguments. Thanks again!
![](/skins/images/3CECF0550DB8BF54496C114A1FF06FE9/responsive_peak/images/icon_anonymous_message.png)
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