User account creation filtered due to spam.

Bug 51076 - [F2008][tracking] Pointer initialization in init expression
Summary: [F2008][tracking] Pointer initialization in init expression
Status: RESOLVED DUPLICATE of bug 51266
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Keywords: rejects-valid
Depends on: 45290 55887
  Show dependency treegraph
Reported: 2011-11-10 10:35 UTC by Tobias Burnus
Modified: 2015-08-30 10:14 UTC (History)
0 users

See Also:
Known to work:
Known to fail:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2011-11-10 10:35:39 UTC
The example is motivated by the discussion at

It seems as is using
  type(T) :: X = t(tgt)
is (should be) valid while using
  type(T), PARAMTER :: X = t(tgt)
is (should be) invalid.

Currently, gfortran rejects both. Note that this is a tracking bug as one seemingly needs to modify the wording to explicitly forbid the usage as PARAMETER, which is technically impossible to implement.

 type(T) :: X = t(tgt) ! Check fails
Error: Parameter 'tgt' at (1) has not been declared or is a variable, which does not reduce to a constant expression

 type :: t
   integer, pointer :: P
 end type t
 integer, target, save :: tgt
 type(T) :: X = t(tgt) ! (1) - a constness check fails
 type(T) :: Y
 Y = t(tgt)   ! (2) Accepted
 Y = t(P=tgt) ! (3) Accepted
Comment 1 Dominique d'Humieres 2015-08-30 10:14:27 UTC

*** This bug has been marked as a duplicate of bug 51266 ***