- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The attached demo of using CFI_allocate to allocate an array in C and return it to the calling Fortran program sometimes results in the run-time error Attempt to fetch from allocatable variable ARRAY when it is not allocated.
commands:
icc -c demo.c
ifort demo.o demo_main.f90 -o demo.exe
is OK but
ifort -check all demo.o demo_main.f90 -o demo.exe
causes the run-time error.
Details: OS is Mac 10.13.6; ifort 2021.1 Beta 20201112.
Thanks for providing the Intel Fortran compiler!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There are (at least) two things wrong here. The first is that the compiler should not be doing pointer/allocatable checks on the call to "demo", since the array argument is allocatable and intent(inout). (I also tested with "out" and got the same behavior.) This is not a "data object reference" (F2018 3.120.1) to array and it's perfectly acceptable to pass an unallocated array to an intent(inout) allocatable dummy. The only time such a diagnostic would be warranted is if the dummy was declared intent(in).
The second, which may cause problems down the road, is that the compiler is not filling in the Intel-only flags and reserved fields in the C descriptor, leaving them as whatever they had before (in my test, hex CCCCCCCC.) This will trip up other parts of the code that expect the flags, at least, to start out as zero.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There are (at least) two things wrong here. The first is that the compiler should not be doing pointer/allocatable checks on the call to "demo", since the array argument is allocatable and intent(inout). (I also tested with "out" and got the same behavior.) This is not a "data object reference" (F2018 3.120.1) to array and it's perfectly acceptable to pass an unallocated array to an intent(inout) allocatable dummy. The only time such a diagnostic would be warranted is if the dummy was declared intent(in).
The second, which may cause problems down the road, is that the compiler is not filling in the Intel-only flags and reserved fields in the C descriptor, leaving them as whatever they had before (in my test, hex CCCCCCCC.) This will trip up other parts of the code that expect the flags, at least, to start out as zero.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your detailed reply.
Will this information reach the compiler developers, or is there somewhere that I should file a bug report?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It might, if an Intel support engineer notices this and picks it up. If you don't have a support license, reports through the Online Service Center would likely get closed. (I do not agree with this policy for simple bug reports.)

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