User account creation filtered due to spam.

Bug 40196 - [F03] [F08] Type parameter inquiry (str%len, a%kind) and Complex parts (z%re, z%im)
Summary: [F03] [F08] Type parameter inquiry (str%len, a%kind) and Complex parts (z%re,...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: unknown
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
Keywords: rejects-valid
Depends on:
Blocks: 20585 39627 29962
  Show dependency treegraph
Reported: 2009-05-19 11:26 UTC by Tobias Burnus
Modified: 2016-01-13 13:35 UTC (History)
6 users (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed: 2009-05-21 20:53:39


Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2009-05-19 11:26:48 UTC
Type parameter inquiry:

str%len   is equivalent to   len(str)
  a%kind  is equivalent to   kind(a)

The real fun part starts with user-defined kinds, e.g.

type tp(dim)
  integer, KIND :: dim
  real :: dist(dim)
end type tp
type(tp) :: t(5)

print *, t%dist%dim

Quote from F2008 but F2003 should be the same:

"A type parameter inquiry is used to inquire about a type parameter of a data object. It applies to both intrinsic and derived types.

R616  type-param-inquiry   is   designator % type-param-name

C622 (R616) The type-param-name shall be the name of a type parameter of the declared type of the object designated by the designator.

A deferred type parameter of a pointer that is not associated or of an unallocated allocatable variable shall not be inquired about."
Comment 1 Tobias Burnus 2009-05-19 11:36:30 UTC
Another related item are complex parts; contrary to the type parameter inquiry above, those are lvalues and can be assigned to. (Again a F2003 feature, quote is however from F2008.)

"R615  complex-part-designator  is  designator % RE
                                or  designator % IM

 C621 (R615) The designator shall be of complex type.

 If complex-part-designator is designator%RE it designates the real part of
 designator. If it is designator%IM it designates the imaginary part of
 designator. The type of a complex-part-designator is real, and its kind and
 shape are those of the designator.

 NOTE 6.6
  The following are examples of complex part designators:

   impedance%re !-- Same value as REAL(impedance)
   fft%im       !-- Same value as AIMAG(fft)
   x%im = 0.0   !-- Sets the imaginary part of X to zero"
Comment 2 Daniel Franke 2009-12-06 16:59:27 UTC
Type parameter inquiries are also mentioned in PR29962, comment #10.
Comment 3 Sean Santos 2013-10-31 16:20:17 UTC
Real/imaginary parts seem to be Fortran 2008 only. Len/kind are still Fortran 2003.