Bug 51266

Summary: [F08] Pointer initialization in PARAMETER
Product: gcc Reporter: Tobias Burnus <burnus>
Component: fortranAssignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: normal CC: janus
Priority: P3 Keywords: rejects-valid
Version: 4.7.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2015-08-30 00:00:00
Bug Depends on: 45290    
Bug Blocks: 39627    

Description Tobias Burnus 2011-11-22 08:50:37 UTC
The following program from
is rejected with:

        TYPE(T), PARAMETER :: C = T(X)  !!!
  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".

        TARGET X
        DATA X/0.0/
        TYPE T
          REAL, POINTER :: P
        END TYPE
        TYPE(T), PARAMETER :: C = T(X)  !!!
        READ *, X
        CALL SUBR()
          REAL, PARAMETER :: Y = C%P  !!!
         PRINT *, Y
Comment 1 Tobias Burnus 2011-11-22 15:44:34 UTC
Hmm, I somehow have the feeling that encountered this bug already. See the thread starting at http://j3-fortran.org/pipermail/j3/2011-November/004840.html

I think I concur with Malcolm that the code of comment 0 cannot be implemented (at least not without combining the linker with the front-end compiler, something no one wants to do):

On the other hand, I think Bob right at
that the current standard seems to have a loop hole.

I probably should have realized the discussion earlier - on the other hand, Bob seems to insist (cf. link above) that the program is not only valid but should also be valid - otherwise, I presume, he wouldn't have posted it at comp.lang.fortran.

(A PR might already exist for this thread.)
Comment 2 janus 2012-04-15 19:55:22 UTC
(In reply to comment #1)
> (A PR might already exist for this thread.)

Well, there is PR 45290 and PR 50410 comment 9, which are at least related.
Comment 3 janus 2012-04-15 20:03:47 UTC
(In reply to comment #2)
> > (A PR might already exist for this thread.)
> Well, there is PR 45290 and PR 50410 comment 9, which are at least related.

And moreover there is PR 51076, which is really identical to this one.
Comment 4 Dominique d'Humieres 2015-08-30 10:14:27 UTC
*** Bug 51076 has been marked as a duplicate of this bug. ***
Comment 5 Dominique d'Humieres 2015-08-30 10:16:18 UTC
The links to  http://j3-fortran.org/pipermail/j3/* are dead!-(