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

ICE on invalid use of optional dummy with VALUE attribute, bind(c) procedure

Harald1
New Contributor II
482 Views

Hello,

the following snippet crashes ifx after emitting a warning for the invalid code:

program p
  implicit none
  call sub ()      ! <- needed for ICE
contains
  subroutine sub (x) bind(c)
    character, value, optional :: x     ! Violates F2018:C865
    if (present(x)) stop 1
  end
end

I get:

 ifx ifort-value-optional-2.f90 -what
 Intel(R) Fortran 24.0-1238.2
ifort-value-optional-2.f90(5): warning #7937: The OPTIONAL attribute should not be used for arguments with the VALUE attribute.   [X]
  subroutine sub (x) bind(c)
------------------^
llfort_create_const_generic: error: invalid type 20
 #0 0x0000000002394d07 (/opt/intel/oneapi/compiler/2024.0/bin/compiler/xfortcom+0x2394d07)
 #1 0x0000000002394cd6 (/opt/intel/oneapi/compiler/2024.0/bin/compiler/xfortcom+0x2394cd6)
 #2 0x0000000002299297 (/opt/intel/oneapi/compiler/2024.0/bin/compiler/xfortcom+0x2299297)
 #3 0x000000000229842f (/opt/intel/oneapi/compiler/2024.0/bin/compiler/xfortcom+0x229842f)
 #4 0x00000000022983f0 (/opt/intel/oneapi/compiler/2024.0/bin/compiler/xfortcom+0x22983f0)
 #5 0x0000000002320719 (/opt/intel/oneapi/compiler/2024.0/bin/compiler/xfortcom+0x2320719)
 #6 0x000000000231f718 (/opt/intel/oneapi/compiler/2024.0/bin/compiler/xfortcom+0x231f718)
 #7 0x000000000231e76c (/opt/intel/oneapi/compiler/2024.0/bin/compiler/xfortcom+0x231e76c)
 #8 0x00000000023e3215 (/opt/intel/oneapi/compiler/2024.0/bin/compiler/xfortcom+0x23e3215)
 #9 0x00000000023e37f5 (/opt/intel/oneapi/compiler/2024.0/bin/compiler/xfortcom+0x23e37f5)
#10 0x00000000023e5f6d (/opt/intel/oneapi/compiler/2024.0/bin/compiler/xfortcom+0x23e5f6d)
#11 0x00000000023e3215 (/opt/intel/oneapi/compiler/2024.0/bin/compiler/xfortcom+0x23e3215)
#12 0x00000000023e05ba (/opt/intel/oneapi/compiler/2024.0/bin/compiler/xfortcom+0x23e05ba)
#13 0x00000000023e3215 (/opt/intel/oneapi/compiler/2024.0/bin/compiler/xfortcom+0x23e3215)
#14 0x00000000022703e6 (/opt/intel/oneapi/compiler/2024.0/bin/compiler/xfortcom+0x22703e6)
#15 0x000000000226fd9e (/opt/intel/oneapi/compiler/2024.0/bin/compiler/xfortcom+0x226fd9e)
#16 0x0000000002452dbe (/opt/intel/oneapi/compiler/2024.0/bin/compiler/xfortcom+0x2452dbe)
#17 0x00007f0a0d78c24d __libc_start_main (/lib64/libc.so.6+0x3524d)
#18 0x00000000020ab129 (/opt/intel/oneapi/compiler/2024.0/bin/compiler/xfortcom+0x20ab129)

ifort-value-optional-2.f90(3): error #5623: **Internal compiler error: internal abort** Please report this error along with the circumstances in which it occurred in a Software Problem Report.  Note: File and line given may not be explicit cause of this error.
  call sub ()      ! <- needed for ICE
--^
compilation aborted for ifort-value-optional-2.f90 (code 3)

ifort does not crash for me.

A minor suggestion: the combination of OPTIONAL+VALUE is only invalid for bind(c) procedures, so mentioning this in the error message might be useful to users.  The standard has:

F2018: C865 A dummy argument of a procedure with the BIND attribute shall not have both the OPTIONAL and VALUE attributes.

 

0 Kudos
2 Replies
TobiasK
Moderator
403 Views

@Harald1

thanks for reporting this. I will escalate it so that we do not ICE but cleanly abort.


0 Kudos
TobiasK
Moderator
274 Views

@Harald1


we implemented a fix which will be included in the 2024.2 release.


0 Kudos
Reply