- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following simple code gives unexpected "error #6773: An equals sign (=) is invalid in this context" with the use of structure constructor in a named constant, but the error doesn't occur in an assignment statement.
module m implicit none integer, parameter :: N = 1 integer, parameter :: C(N) = [ 0 ] type :: t integer :: x(N) end type t contains subroutine foo() type(t) :: t1 type(t), parameter :: t2 = t( x = C ) t1 = t( x = C ) return end subroutine foo end module m
I'm using the initial release of compiler 16 (v16.0.0.110):
Compiling with Intel(R) Visual Fortran Compiler 16.0 [Intel(R) 64]... m.f90 m.f90(18): error #6773: An equals sign (=) is invalid in this context.compilation aborted for m.f90 (code 1)
I can't find anything in the standard suggesting anything invalid with the above shown structure constructor in a named constant as opposed to the assignment, but may be I'm missing something. I appreciate feedback on this error.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
FWIW, the above code compiles with no errors in gfortran and a test executes as expected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you FortranFan. I will investigate this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A blast from the past! Here's some sidebar tidbit.
When I try a slight variant of the code in the original post, I get the following error in Compaq Visual Fortran:
--------------------Configuration: m - Win32 Debug-------------------- Compiling Fortran... m.f90 m.f90(19) : Error: An equals sign (=) is invalid in this context.t1 = t( x = C ) --------------^ Error executing df.exe. m.obj - 1 error(s), 0 warning(s)
The code is:
module m implicit none integer, parameter :: N = 1 integer, parameter :: C(N) = (/ 0 /) type :: t integer :: x(N) end type t contains subroutine foo() type(t) :: t1 t1 = t( x = C ) return end subroutine foo end module m
Now this particular code variant works in the current Intel compiler, but it's interesting how the text of the error from Compaq Visual Fortran is exactly the same as in the current compiler, illustrating its roots! It makes sense that Compaq Visual Fortran would throw an error since structure constructor with named arguments was only introduced starting with the Fortran 2003 standard. Is this a case where the compiler, when updated to support Fortran 2003, had things fixed up for processing of assignment statements but not for named constants?! :-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I reported this to Development and will let you know what I hear back.
(Internal tracking id: DPD200376064)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Kevin Davis (Intel) wrote:
I reported this to Development and will let you know what I hear back.
(Internal tracking id: DPD200376064)
Ok, thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For whatever reason, the following variant of the code in the original post is accepted by the compiler:
module m implicit none integer, parameter :: N = 1 integer, parameter :: C(N) = [ 0 ] type :: t integer :: x(N) end type t contains subroutine foo() integer :: i type(t), parameter :: t1 = t( x = [ (C(i), i=1,N) ] ) return end subroutine foo end module m
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Interesting. Thanks for the info. I added this variant to the earlier internal tracking id noted.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page