* [Bug fortran/59411] Problem with TYPE(C_PTR) constant initialization
2013-12-06 16:39 [Bug fortran/59411] New: Problem with TYPE(C_PTR) constant initialization mrestelli at gmail dot com
@ 2013-12-07 16:29 ` janus at gcc dot gnu.org
2013-12-07 16:37 ` janus at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: janus at gcc dot gnu.org @ 2013-12-07 16:29 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59411
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |janus at gcc dot gnu.org
--- Comment #1 from janus at gcc dot gnu.org ---
(In reply to mrestelli from comment #0)
>
> type(c_ptr), parameter :: p2 = pp
> 1
> Error: non-constant initialization expression at (1)
>
> However, as far as I can tell, the code is correct (ifort accepts it).
well, just because ifort accepts it doesn't mean that it's valid.
In fact the corresponing case with actual Fortran pointers (i.e. pointer
initialization) is only allowed since F08, cf. PR45290. One should check the
Fortran standard for restrictions in the case of C_PTRs (which, strictly
speaking, are no actual pointers in the Fortran sense).
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/59411] Problem with TYPE(C_PTR) constant initialization
2013-12-06 16:39 [Bug fortran/59411] New: Problem with TYPE(C_PTR) constant initialization mrestelli at gmail dot com
2013-12-07 16:29 ` [Bug fortran/59411] " janus at gcc dot gnu.org
@ 2013-12-07 16:37 ` janus at gcc dot gnu.org
2013-12-07 17:12 ` janus at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: janus at gcc dot gnu.org @ 2013-12-07 16:37 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59411
--- Comment #2 from janus at gcc dot gnu.org ---
(In reply to janus from comment #1)
> One should check the
> Fortran standard for restrictions in the case of C_PTRs (which, strictly
> speaking, are no actual pointers in the Fortran sense).
Since C_PTR is a derived type in the Fortran sense, I don't see why any
restrictions on pointer init should apply.
Unless there are any special restrictions for C_PTR, the code should be valid,
just as the corresponding code with any other derived type:
module m
implicit none
type :: t
end type
type(t), parameter :: pp = t()
type(t), parameter :: p2 = pp
end module m
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/59411] Problem with TYPE(C_PTR) constant initialization
2013-12-06 16:39 [Bug fortran/59411] New: Problem with TYPE(C_PTR) constant initialization mrestelli at gmail dot com
2013-12-07 16:29 ` [Bug fortran/59411] " janus at gcc dot gnu.org
2013-12-07 16:37 ` janus at gcc dot gnu.org
@ 2013-12-07 17:12 ` janus at gcc dot gnu.org
2013-12-09 8:09 ` mrestelli at gmail dot com
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: janus at gcc dot gnu.org @ 2013-12-07 17:12 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59411
--- Comment #3 from janus at gcc dot gnu.org ---
In F03, I think the relevant quotes are:
R506 initialization is = initialization-expr
or => null-init
7.1.7 Initialization expression
An initialization expression is an expression with limitations that make it
suitable for use as a kind type parameter, initializer, or named constant. It
is an expression in which each operation is intrinsic, and each primary is
(1) A constant or subobject of a constant,
...
Since pp is clearly a constant, the code should be valid (probably also in
F08).
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/59411] Problem with TYPE(C_PTR) constant initialization
2013-12-06 16:39 [Bug fortran/59411] New: Problem with TYPE(C_PTR) constant initialization mrestelli at gmail dot com
` (2 preceding siblings ...)
2013-12-07 17:12 ` janus at gcc dot gnu.org
@ 2013-12-09 8:09 ` mrestelli at gmail dot com
2013-12-09 9:58 ` janus at gcc dot gnu.org
2013-12-18 12:32 ` [Bug fortran/59411] [F03] " dominiq at lps dot ens.fr
5 siblings, 0 replies; 7+ messages in thread
From: mrestelli at gmail dot com @ 2013-12-09 8:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59411
--- Comment #4 from mrestelli <mrestelli at gmail dot com> ---
(In reply to janus from comment #1)
> (In reply to mrestelli from comment #0)
> >
> > type(c_ptr), parameter :: p2 = pp
> > 1
> > Error: non-constant initialization expression at (1)
> >
> > However, as far as I can tell, the code is correct (ifort accepts it).
>
> well, just because ifort accepts it doesn't mean that it's valid.
Janus, yes, of course you are right, what I wanted to say was that the
code seems fine according to my understanding of what "should happen",
and for what is worth also ifort is happy with it. But I see that my
sentence was not clear.
Thank you for checking the relevant text in the standard, and also for
the nice example
type(t), parameter :: pp = suitable_initialization_expr_for_type_t
type(t), parameter :: p2 = pp
I would assume that, provided the first assignment is correct, the
second one is always correct, whatever the definition of type(t). Am I
right?
Marco
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/59411] Problem with TYPE(C_PTR) constant initialization
2013-12-06 16:39 [Bug fortran/59411] New: Problem with TYPE(C_PTR) constant initialization mrestelli at gmail dot com
` (3 preceding siblings ...)
2013-12-09 8:09 ` mrestelli at gmail dot com
@ 2013-12-09 9:58 ` janus at gcc dot gnu.org
2013-12-18 12:32 ` [Bug fortran/59411] [F03] " dominiq at lps dot ens.fr
5 siblings, 0 replies; 7+ messages in thread
From: janus at gcc dot gnu.org @ 2013-12-09 9:58 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59411
--- Comment #5 from janus at gcc dot gnu.org ---
(In reply to mrestelli from comment #4)
> type(t), parameter :: pp = suitable_initialization_expr_for_type_t
> type(t), parameter :: p2 = pp
>
> I would assume that, provided the first assignment is correct, the
> second one is always correct, whatever the definition of type(t). Am I
> right?
I would think so. It is important, though, that pp is a PARAMETER.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/59411] [F03] Problem with TYPE(C_PTR) constant initialization
2013-12-06 16:39 [Bug fortran/59411] New: Problem with TYPE(C_PTR) constant initialization mrestelli at gmail dot com
` (4 preceding siblings ...)
2013-12-09 9:58 ` janus at gcc dot gnu.org
@ 2013-12-18 12:32 ` dominiq at lps dot ens.fr
5 siblings, 0 replies; 7+ messages in thread
From: dominiq at lps dot ens.fr @ 2013-12-18 12:32 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59411
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-12-18
Ever confirmed|0 |1
--- Comment #6 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Confirmed at r206083.
^ permalink raw reply [flat|nested] 7+ messages in thread