Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
26745 Discussions

Bug with pointer to component of allocated type

Siewert__Christoph
94 Views
I believe I finally found a nasty compiler bug. Starting with compiler version intel/2017.5.239 up to the most recent avaiable for me intel/2019.0.117, there is a problem with pointing to a component of an allocated derived type. Opposing to the expectation using the pointer modifies always the first component of type instead of the one that it is pointing to. The following minimal reproducer compiled with -O0 returns:

 F F

In the example it is only output, however, it works also wrong for modifying, even with the type components have different POD types. The intel compiler 2016 and earlier shows the expected behavoir.

PROGRAM main
  IMPLICIT NONE

  TYPE t_traj
    LOGICAL :: a = .FALSE.
    LOGICAL :: b = .TRUE.
  END TYPE t_traj

  INTEGER, PARAMETER :: noPart = 3
  TYPE(t_traj), TARGET, ALLOCATABLE :: sps(:)
  LOGICAL, POINTER :: p_point(:)
  ALLOCATE( sps(noPart) )

  p_point(1:noPart-1) => sps(1:noPart-1)%b
  WRITE(*,*) p_point

  DEALLOCATE( sps )
END PROGRAM main

 

0 Kudos
1 Reply
Juergen_R_R
Valued Contributor I
94 Views

This indeed looks like a compiler bug. Please submit it through the Online Support Center.

Reply