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!
26758 Discussions

Compiler accepts invalid code without warnings or errors

mecej4
Black Belt
152 Views

The following source contains a spurious '&' in the middle of the ninth line. According to the Fortran standard, in free form source a '&' that is not inside a character string must be followed by an end of line or a comment. The Intel Fortran compiler on Windows, 19.1U1, does not recognize this error, and produces an object file!

Program PassString2C
   use, intrinsic :: iso_c_binding, only: c_char, c_null_char
   interface
      subroutine copy(in, out) bind(c, name = 'copy')
         import c_char
         character(kind=c_char), dimension(*) :: in, out
      end subroutine copy
   end interface
   character(len=10, kind=c_char) :: & digit_string = &                 ! First '&' is a typo
      c_char_'123456789' // c_null_char
   character(kind=c_char) :: digit_arr(10)
   call copy(digit_string, digit_arr)
   print '(1x, 9a1)', digit_arr(1:9)
end Program

I created a support ticket (04579584) two days ago. Today I was told that I was not eligible for support and that I should report the bug in this forum. 

0 Kudos
3 Replies
FortranFan
Honored Contributor II
152 Views

Thanks for posting this.  Intel Fortran compiler issues no relevant error or warning with this variant as well:

   integer :: & i = 42
end

A support request has been submitted with both the cases: # 04584009.

FortranFan
Honored Contributor II
152 Views

FortranFan wrote:

Thanks for posting this.  Intel Fortran compiler issues no relevant error or warning with this variant as well:

   integer :: & i = 42
end

A support request has been submitted with both the cases: # 04584009.

C:\Temp>type p.f90
   integer :: & i = 42
end

C:\Temp>gfortran p.f90
p.f90:1:16:

    1 |    integer :: & i = 42
      |                1
Error: Invalid character in name at (1)

C:\Temp>

 

mecej4
Black Belt
152 Views

Thank you. 

Older versions of Ifort have this bug, too.

Reply