Bug 51266 - [F08] Pointer initialization in PARAMETER
Summary: [F08] Pointer initialization in PARAMETER
Status: NEW
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
URL:
Keywords: rejects-valid
: 51076 (view as bug list)
Depends on: 45290
Blocks: F2008
  Show dependency treegraph
 
Reported: 2011-11-22 08:50 UTC by Tobias Burnus
Modified: 2015-10-09 08:50 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-08-30 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2011-11-22 08:50:37 UTC
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
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):
  http://j3-fortran.org/pipermail/j3/2011-November/004851.html

On the other hand, I think Bob right at
  http://j3-fortran.org/pipermail/j3/2011-November/004857.html
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!-(