Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28455 Discussions

Bug with pointer to component of allocated type

Siewert__Christoph
367 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
367 Views

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

0 Kudos
Reply