- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Original stack overflow question https://stackoverflow.com/questions/76766405/problem-allocating-logical-from-class-using-source-in-fortran/76773359#76773359
The following code produces random (though heavily biased) results.
Program LogicalAllocation
implicit none class(*), pointer :: bool allocate(bool, source=.false.) select type(bool) type is (logical) Print *, bool end select
End Program LogicalAllocation
On my intel fortran oneapi version 2023.0.0.25839 this code will print 'T' or 'F' seemingly at random. Using iFort
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I only get F consistently with recent oneapi update, ifort (2021.10.0 20230609) and ifx(2023.2.0 20230622) .
However, checking with valgrind I see "Conditional jump or move depends on uninitialised value(s)" at the write line, probably accessing the value of bool, as valgrind further states that the "Uninitialised value was created by a heap allocation" and points at the allocate line. That looks like a bug in ifort.
With ifx the output looks clean and no errors are shown by valgrind.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page