Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
22 Views

Nested array constructors with type spec

Hello all,

the following code is in my opinion wrongly rejected:

  print *,              [ integer :: ], 1    ! OK                                
  print *, [ integer :: [ integer :: ], 1 ]  ! Fail                              
end
% ifort bug.f90 -stand f08
bug.f90(2): error #7203: An ac-value-list of an array-constructor must contain at least one ac-value.
  print *, [ integer :: [ integer :: ], 1 ]  ! Fail
--------------------------^
compilation aborted for bug.f90 (code 1)

The code is accepted by the Cray compiler.

 

0 Kudos
4 Replies
Highlighted
Black Belt Retired Employee
22 Views

I agree - bug. The array constructor with a type-spec but no ac-value-list creates a zero-length array. The second statement's outer array constructor has as its values the empty array and 1 - in this case the empty array would not contribute to the array.

0 Kudos
Highlighted
22 Views

I have opened a bug report for it. The track ID is DPD200419522.

 

Thanks,

Xiaoping Duan

Intel Customer Support

0 Kudos
Highlighted
22 Views

Steve,

Can you comment on the validity of (I assume not valid):

print *, [ integer :: [ real :: 1.0], 1 ]

Does this imply a real to integer conversion, or does it choke with incompatible types?

Note, in lieu of the inner real one might specify a type that has no implicit conversion to outer type.

Jim Dempsey

0 Kudos
Highlighted
Black Belt Retired Employee
22 Views

Jim, that would be allowed and it would convert the REAL value(s) to INTEGER according to the rules for intrinsic assignment. The text from the standard related to this is:

C4104 (R469) If type-spec specifies an intrinsic type, each ac-value expression in the array-constructor shall be of an intrinsic type that is in type conformance with a variable of type type-spec as specified in Table 7.8.

Table 7.8: Type conformance for the intrinsic assignment statement
Type of the variable Type of expr
integer integer, real, complex
real integer, real, complex
complex integer, real, complex
character character
logical logical
derived type same derived type as the variable

0 Kudos