Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
The Intel sign-in experience is changing in February to support enhanced security controls. If you sign in, click here for more information.

Bug with IFX?

Robert_van_Amerongen
New Contributor III
271 Views

As it becomes time to move from the classic compiler to the new IFX compiler, I start to use the IFX compiler. My first attempt, however, failed when calling C_F_POINTER. The compiler invites me friendly to report this internal compiler error. So here I am.

With the classic compiler I did not see this error for either this example as many other projects where I use it. I have enclosed a small example.

 

Robert

 

0 Kudos
5 Replies
Steve_Lionel
Black Belt Retired Employee
255 Views

Just a general comment - it is helpful for others to give a more descriptive title to threads here. You could have written something like "ICE with IFX and C_F_POINTER".

FortranFan
Honored Contributor II
236 Views

@Robert_van_Amerongen ,

You can always claim an "internal compiler error" (ICE) is a bug and as pointed to you, mentioning ICE in the thread title itself can help catch the attention of Intel team.

Separately, if your interest is in an "early" implementation of the Fortran 2023 "c_f_strpointer" intrinsic module procedure, you may want to consider simplifying greatly what you are doing, avoid any unnecessary allocations, etc.  Here's a snippet you can try with the new compiler, especially IFX - note I haven't tested it, it's a quick edit on a tab based on your example with my mental compiler:

module cstring_m
   use, intrinsic :: iso_c_binding, only : c_char, c_size_t, c_ptr, c_f_pointer
   generic :: c_f_strpointer => c_f_strpointer_cstrptr
contains
   subroutine c_f_strpointer_cstrptr( cstrptr, fstrptr, nchars )
      ! Argument list
      type(c_ptr), intent(in)                             :: cstrptr
      character(kind=c_char, len=:), pointer, intent(out) :: fstrptr
      integer(c_size_t), intent(in)                       :: nchars
      if ( nchars >= 0 ) then
         block 
            character(kind=c_char, len=nchars), pointer :: sptr
            call c_f_pointer( cstrptr, sptr )
            fstrptr => sptr
            sptr => null()
         end block
      end if
      return
   end subroutine 
end module
   use, intrinsic :: iso_c_binding, only : c_char, c_null_char, c_loc, c_size_t
   use cstring_m, only : c_f_strpointer
   character(kind=c_char, len=:), allocatable, target :: s
   character(kind=c_char, len=:), pointer :: ps
   s = c_char_"This is a test string!" // c_null_char
   call c_f_strpointer( c_loc(s), ps, nchars=22_c_size_t )
   print *, "ps: ", ps
   print *, "len_trim(ps) = ", len_trim(ps), "; expected is 22"
end

 

Steve_Lionel
Black Belt Retired Employee
232 Views

@FortranFan 's example compiles successfully with ifx.

Ron_Green
Moderator
215 Views

Thanks for sending this. The bug ID is CMPLRLLVM-43336


Robert_van_Amerongen
New Contributor III
202 Views

Thank all of you for your help. As FortranFan suggests, the routine was written to have it available as soon as possible. The new standard has a series of new procedures that are very, very, welcome. The C-string helpers are one of these.

 

In the mean time I found some other ICE's . I will take a cl.oser look to see if these are related with the ICE here; I will let you know.

 

Robert

 

Reply