- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following code generates a stack overflow on Windows (for a standard 1MB stack) even when compiled with default "Release" settings.
module test
contains
subroutine add_lines()
character(500):: line
integer:: loop_file
character(500),dimension(:),allocatable:: c
allocate(c(0))
c = ''
do loop_file=1,10000
line = 'abcd'
c = [character(len=500) :: c , line]
end do
end subroutine
end module test
program Console1
use test
implicit none
call add_lines()
end program Console1
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This example is curious. I also see the stack exhaustion. I can prevent it by adding -heap-arrays. But it still should not need this option.
I need to investigate this more. it's not obvious to me why the constructor would blow up stack. It should only use 500 chars of storage. Might be that the RHS constructor is not being freed up after the copy to the LHS. Just a suspicion.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, I also just found out that -heap-arrays (even with sizes far greater than the stack size) prevents it.
But without -heap-arrays:
While debugging through the loop, the stack-pointer is growing all the time. After leaving "add_lines" the stack-pointer has the correct value again (when the loop-counter is below the stack-overflow limit, of course).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
BugID is CMPLRLLVM-69147

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