Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Объявления
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29280 Обсуждение

PDT: KIND and LEN type parameters are mutually exclusive

Harald1
Новый участник II
1 693Просмотр.

The following invalid code is erroneously accepted by ifort 2021.4.0:

  type :: bad_pdt (k,l)
     integer, kind, len      :: k = 1
     integer, len, kind      :: l = 1
     character(kind=k,len=l) :: c
  end type bad_pdt
end

 The Fortran 2018 standard (and similarly 2003+) state:

 

F2018: 7.5.3.1  Type parameter definition statement

R732  type-param-def-stmt is
      integer-type-spec, type-param-attr-spec :: type-param-decl-list

R734  type-param-attr-spec  is KIND or LEN

(3) The type-param-attr-spec explicitly specifies whether a type parameter is a kind parameter or a length parameter.

Thus the KIND and LEN attributes are mutually exclusive.

The correct solution would be to reject the code sample.

 

Thanks,

Harald

 

0 баллов
1 Решение
Barbara_P_Intel
Сотрудник
1 619Просмотр.

I filed a bug report on this issue for you, CMPLRIL0-34368. I'll let you know when a fix is available.



Просмотреть решение в исходном сообщении

6 Ответы
jimdempseyatthecove
Почетный участник III
1 663Просмотр.

FWIW your type declaration is (may be) non-conformant. From:

   A type declaration has the general form:

   type-spec[ [, att] ... ::] v[/c-list/][, v[/c-list/]] ...
Thus your:
...
  integer, kind, len  :: k = 1
 
Is ?ambiguous??
 
The presence of the "integer, kind, len" part of the statement are of the old/legacy format declaring kind and len as integers. However, you statement contains "::", which now state that the ", kind, len" portion are attributes. So, which are they? Attributes or variables of integer type? If attribute, there is no attribute named "kind" nor "len".
 
Jim Dempsey
Harald1
Новый участник II
1 652Просмотр.

Jim,

 

I was talking about F2003 parameterized derived types.  I wouldn't call that "old/legacy" yet.  Maybe you are thinking of some old/legacy DEC/Intel extension?

The compiler should provide a means to reject non-standard-conforming code.  The above sample violates F2018:R734.  "ifort -stand" remains quiet.

 

Harald

 

Steve_Lionel
Почетный участник III
1 637Просмотр.

I agree that the compiler should complain. This is not an extension, just a lack of error checking.

Barbara_P_Intel
Сотрудник
1 620Просмотр.

I filed a bug report on this issue for you, CMPLRIL0-34368. I'll let you know when a fix is available.



Barbara_P_Intel
Сотрудник
1 015Просмотр.

With the 2024.1 release both ifx and ifort are printing error messages.

These compilers were made available last week. Please try them!



Harald1
Новый участник II
979Просмотр.

It is indeed diagnosed properly now.  Thanks!

 

Ответить