- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was experimenting with pointer rank remapping, and discovered some unexpected results when the pointer and target were unlimited polymorphic. I'm not certain about the code though -- feels a bit sketchy -- however I wasn't able to find anything in the 2003 standard that excludes a polymorphic target and pointer from pointer rank remapping. The compiler doesn't complain -- only the results are wrong/unexpected. Here's the code
program main class(*), allocatable, target :: array(:) class(*), pointer :: ptr(:,:) allocate(array, source=[1,2,3,4]) ptr(1:2,1:2) => array select type (ptr) type is (integer) print *, 'expect 1 2 3 4:', ptr print *, 'expect 1 3:', ptr(1,:) print *, 'expect 2 4:', ptr(2,:) print *, 'expect 1 2:', ptr(:,1) print *, 'expect 3 4:', ptr(:,2) end select end program
The results with the 14.0.2 compiler are:
expect 1 2 3 4: 1 2 3 4 expect 1 3: 538976288 538976288 expect 2 4: 538976288 538976288 expect 1 2: 1 2 expect 3 4: 1 2
Is the compiler generating bad code, or is the code not standard and the compiler just isn't complaining (kind of a bug too)? Thoughts?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Looks like a bug in Intel 14.0.2 compiler version - have you tried in Intel 2015 Beta version? The program runs as expected in gfortran 4.9.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I do not know whether the program is fully conforming and will lean on Development (or others in the Forum) for help regarding that. I did confirm the unexpected results occur when using the 14.0 and current 2015 Beta compilers and reported the issue to Development (see internal tracking id below) for further investigation and will let you know what I hear back.
(Internal tracking id: DPD200357656)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The code is standard-conforming.

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