- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tell me I'm doing something stupid here:
[plain]module mod1
implicit none
contains
subroutine bar(k)
integer, optional :: k
#ifdef FAIL
k = 1
#endif
end subroutine bar
!
end module mod1
program main
!
use mod1
call bar()
!
end program main
[/plain]
OK now compile and run w/o FAIL being set:
[plain]pwill@zarathustra:~/samba$ ifort pain.F90
pwill@zarathustra:~/samba$ ./a.out
pwill@zarathustra:~/samba$
[/plain]
OK now redo compile/run with -DFAIL flag set, to include the code that would otherwise be commented out:
[plain]pwill@zarathustra:~/samba$ ifort pain.F90 -DFAIL
pwill@zarathustra:~/samba$ ./a.out
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image PC Routine Line Source
a.out 0000000000402B24 Unknown Unknown Unknown
a.out 0000000000402ADC Unknown Unknown Unknown
libc.so.6 00007F9F1941E5A6 Unknown Unknown Unknown
a.out 00000000004029D9 Unknown Unknown Unknown
pwill@zarathustra:~/samba$
[/plain]
So, it appears that merely testing for the presence of setting an optional argument is now making the code SIGSEGV.
Am I missing something? Am I not allowed to set optional arguments?
Peter
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is illegal to access a non-present optional argument. Steve has an nice discussion in The Virtues of Omission.
These previous threads contains similar discussions:
http://software.intel.com/en-us/forums/showthread.php?t=53378
http://software.intel.com/en-us/forums/showthread.php?t=53122
http://software.intel.com/en-us/forums/showthread.php?t=60046
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
P.S. I've edited the code to make it even more succinct (as should now be reflected in posting - first version was a bit lengthy)... anyway still fails in same manner.
Oh yes: Intel 64, Version 11.1, Build 20090630 Package ID: l_cprof_p_11.1.046, on Ubuntu 9.04 x86_64.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is illegal to access a non-present optional argument. Steve has an nice discussion in The Virtues of Omission.
These previous threads contains similar discussions:
http://software.intel.com/en-us/forums/showthread.php?t=53378
http://software.intel.com/en-us/forums/showthread.php?t=53122
http://software.intel.com/en-us/forums/showthread.php?t=60046
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ahhh. Thanks. Switch that from "compiler error" to "keyboard-chair interface error". :)
I've read Steve's post as you suggest. Every other feature of optional arguments makes sense - but not being able to access them if they aren't passed, that was a surprise to me. But I guess it makes complete and total sense when you remember that Fortran is pass-by-reference and not pass-by-value (obviously Fortran isn't my first language!).
Now the SIGSEGV also makes complete sense - I'm trying to write to memory off in the middle of nowhere somewhere! I suppose that should have been a hint.....
Peter
I've read Steve's post as you suggest. Every other feature of optional arguments makes sense - but not being able to access them if they aren't passed, that was a surprise to me. But I guess it makes complete and total sense when you remember that Fortran is pass-by-reference and not pass-by-value (obviously Fortran isn't my first language!).
Now the SIGSEGV also makes complete sense - I'm trying to write to memory off in the middle of nowhere somewhere! I suppose that should have been a hint.....
Peter

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