Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Black Belt
1 View

Compiler accepts invalid code without warnings or errors

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
Highlighted
Valued Contributor III
1 View

Thanks for posting this. 

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.

0 Kudos
Highlighted
Valued Contributor III
1 View

Quote:FortranFan wrote:

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>

 

0 Kudos
Highlighted
Black Belt
1 View

Thank you. 

Thank you. 

Older versions of Ifort have this bug, too.

0 Kudos