http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51266
Bug #: 51266 Summary: Pointer initialization in PARAMETER Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: bur...@gcc.gnu.org Blocks: 45290 The following program from http://groups.google.com/group/comp.lang.fortran/msg/38bbc52c641f4b13 is rejected with: TYPE(T), PARAMETER :: C = T(X) !!! 1 Error: Parameter 'x' at (1) has not been declared or is a variable, which does not reduce to a constant expression The check is wrong as one has a pointer initialization - and X is a valid REAL, TARGET, SAVE variable. Without PARAMETER, the initialization works. I think just the checking needs to be fixed. (Note this is a F2008 feature.) Variant: Use "T()" an in the derived type "P => X". PROGRAM MAIN TARGET X DATA X/0.0/ TYPE T REAL, POINTER :: P END TYPE TYPE(T), PARAMETER :: C = T(X) !!! READ *, X CALL SUBR() CONTAINS SUBROUTINE SUBR REAL, PARAMETER :: Y = C%P !!! PRINT *, Y END SUBROUTINE END