- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a problem which occurs on x64 but not win32. I have a c++ routine which declares a character string
char string[16]
and passes it to fortran which gives string a value
string = 'abc'
This results in an error: "A buffer overrun has occurred in post.exe which has corrupted the program's internal state. Press Break to debug the program or Continue to terminate the program."
If I change the code to
string(1:len(string)) = 'abc'
the error changes to "Variable STRING has substring ending point 16 which is greater than the variable length of 16".
I cannt reproduce either error in 10 lines of code, so it's difficult for support to help me. Any ideas or work-arounds would be most welcome.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If your C++ code expects a null terminated string, you should initialize it accordingly. Aside from special facilities of ifort, you might use 'abc'//achar(0)
You might have been lucky in the 32-bit version to have an acceptable terminating character appear in the buffer.
I'm guessing, as that's about all that can be done with the information you presented.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How is string declared on the Fortran side?
If it is (0:15) as opposed to (1:16) then you may see this problem.
The IFORT documentation is not clear on this issue. I suggest placing a break point on the assignment causing the problem. Then examin STRING in the debugger to find the array indicies (see if it is 0:15 or 1:16, or something else).
Jim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Chris.Biddlecombe@vectorfields.co.uk:
The debugger knows it is CHARACTER(16) and the LEN function gets that right too. But how can 16 be greater than 16? If I try setting characters 1 to 15, it tells me that 15 is greater than 16!
Try 17, then
![Smiley with tongue out [:-P]](/isn/Community/en-US/emoticons/emotion-4.gif)
But seriously, this now sounds like an issue for Premier support; either you discovered a compiler bug, or you made a fandango on core elsewhere.

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