- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Following program crashes on Linux/x86_64/intel fortran (also gfortran & NAG fortran)
program chk_trim
CHARACTER*(30) TAB
TAB='RSRDATA_AAAAAA\0'
call shady(tab) !! 1st call does not seg fault
!! as TAB string is on the stack
call shady('RSRDATA_BBBBBB\0') !! this seg faults
!! since string passed in argument
!! is in non-writable memory region
write(*,*) 'tab=',tab
end program
SUBROUTINE SHADY(TAB)
CHARACTER*(16) TAB
TAB = TRIM(TAB) !! -- CRASHES HERE --
write(*,*) '--## TAB=', TAB
RETURN
END
But surprisingly it does not crash on AIX xlf95 (PowerPC). Nevertheless, it looks like invalid Fortran code - is this right?
BR, Jan.
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That's why interface and intent has been added to fortran. Before that, it was a common problem leading to crash or constant value change depending of compiler constant implementation.
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