* [Bug fortran/61275] Invalid initialization expression for ALLOCATABLE component in structure constructor at (1)
2014-05-21 16:05 [Bug fortran/61275] New: Invalid initialization expression for ALLOCATABLE component in structure constructor at (1) antony at cosmologist dot info
@ 2014-05-23 15:09 ` dominiq at lps dot ens.fr
2015-01-17 18:09 ` pault at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-05-23 15:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61275
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-05-23
CC| |pault at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Confirmed on 4.9.0 and trunk (4.10).
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/61275] Invalid initialization expression for ALLOCATABLE component in structure constructor at (1)
2014-05-21 16:05 [Bug fortran/61275] New: Invalid initialization expression for ALLOCATABLE component in structure constructor at (1) antony at cosmologist dot info
2014-05-23 15:09 ` [Bug fortran/61275] " dominiq at lps dot ens.fr
@ 2015-01-17 18:09 ` pault at gcc dot gnu.org
2015-01-23 11:26 ` vehre at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pault at gcc dot gnu.org @ 2015-01-17 18:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61275
--- Comment #2 from Paul Thomas <pault at gcc dot gnu.org> ---
Author: pault
Date: Sat Jan 17 18:08:38 2015
New Revision: 219801
URL: https://gcc.gnu.org/viewcvs?rev=219801&root=gcc&view=rev
Log:
2015-01-17 Andre Vehreschild <vehre@gmx.de>
PR fortran/60357
* primary.c (build_actual_constructor): Prevent warning.
* trans-expr.c (alloc_scalar_allocatable_for_subcomponent_
assignment): New function encapsulates treatment of allocatable
components.
(gfc_trans_subcomponent_assign): Needed to distinguish between
regular assignment and initilization.
(gfc_trans_structure_assign): Same.
(gfc_conv_structure): Same.
PR fortran/61275
* gfortran.h: deferred_parameter is not needed, because
it artificial does the trick completely.
* primary.c (build_actual_constructor): Same.
(gfc_convert_to_structure_constructor): Same.
* resolve.c (resolve_fl_derived0): Same.
* trans-expr.c (gfc_conv_component_ref): Prevent treating
allocatable deferred length char arrays here.
(gfc_trans_subcomponent_assign): Same as above.
* trans-types.c (gfc_sym_type): This is done in
gfc_get_derived_type already.
2015-01-17 Andre Vehreschild <vehre@gmx.de>
PR fortran/60357
* gfortran.dg/alloc_comp_assign_13.f08: New test.
PR fortran/61275
* gfortran.dg/alloc_comp_assign_14.f08: New test.
PR fortran/55932
* gfortran.dg/alloc_comp_initializer_4.f03: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/alloc_comp_assign_13.f08
trunk/gcc/testsuite/gfortran.dg/alloc_comp_assign_14.f08
trunk/gcc/testsuite/gfortran.dg/alloc_comp_initializer_4.f03
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/gfortran.h
trunk/gcc/fortran/primary.c
trunk/gcc/fortran/resolve.c
trunk/gcc/fortran/trans-expr.c
trunk/gcc/fortran/trans-types.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/61275] Invalid initialization expression for ALLOCATABLE component in structure constructor at (1)
2014-05-21 16:05 [Bug fortran/61275] New: Invalid initialization expression for ALLOCATABLE component in structure constructor at (1) antony at cosmologist dot info
2014-05-23 15:09 ` [Bug fortran/61275] " dominiq at lps dot ens.fr
2015-01-17 18:09 ` pault at gcc dot gnu.org
@ 2015-01-23 11:26 ` vehre at gcc dot gnu.org
2015-03-20 11:58 ` dominiq at lps dot ens.fr
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: vehre at gcc dot gnu.org @ 2015-01-23 11:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61275
vehre at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |vehre at gcc dot gnu.org
Resolution|--- |FIXED
Assignee|unassigned at gcc dot gnu.org |vehre at gcc dot gnu.org
--- Comment #3 from vehre at gcc dot gnu.org ---
Resolved with commit r219801.
Thanks Paul for commiting.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/61275] Invalid initialization expression for ALLOCATABLE component in structure constructor at (1)
2014-05-21 16:05 [Bug fortran/61275] New: Invalid initialization expression for ALLOCATABLE component in structure constructor at (1) antony at cosmologist dot info
` (2 preceding siblings ...)
2015-01-23 11:26 ` vehre at gcc dot gnu.org
@ 2015-03-20 11:58 ` dominiq at lps dot ens.fr
2015-03-20 12:19 ` vehre at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-03-20 11:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61275
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|FIXED |---
--- Comment #4 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Sorry for the late reaction, but the original test is still giving the same
error with a clean tree at r221069.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/61275] Invalid initialization expression for ALLOCATABLE component in structure constructor at (1)
2014-05-21 16:05 [Bug fortran/61275] New: Invalid initialization expression for ALLOCATABLE component in structure constructor at (1) antony at cosmologist dot info
` (3 preceding siblings ...)
2015-03-20 11:58 ` dominiq at lps dot ens.fr
@ 2015-03-20 12:19 ` vehre at gcc dot gnu.org
2015-03-20 13:13 ` antony at cosmologist dot info
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: vehre at gcc dot gnu.org @ 2015-03-20 12:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61275
--- Comment #5 from vehre at gcc dot gnu.org ---
Completely right, the initial test is still not compilable. But this is because
assigning to an allocatable component in an initializer is not allowed by the
standards:
F2003, 7.1.7 (3) and also in
F2008, 7.1.12 (3).
So the correct code would be:
module A
Type T
character(LEN=:), allocatable :: S
end type
Type(T) :: TestObj = T(NULL())
TestObj%S = 'string'
contains
end module
which compiles and runs w/o error.
Standard compliant implementation is tested for in
gfortran.dg/alloc_comp_init_expr.f03
only far allocatable arrays, but that's near enough for char arrays for me.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/61275] Invalid initialization expression for ALLOCATABLE component in structure constructor at (1)
2014-05-21 16:05 [Bug fortran/61275] New: Invalid initialization expression for ALLOCATABLE component in structure constructor at (1) antony at cosmologist dot info
` (4 preceding siblings ...)
2015-03-20 12:19 ` vehre at gcc dot gnu.org
@ 2015-03-20 13:13 ` antony at cosmologist dot info
2015-03-20 13:51 ` vehre at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: antony at cosmologist dot info @ 2015-03-20 13:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61275
--- Comment #6 from Antony Lewis <antony at cosmologist dot info> ---
Not sure about that - 7.1.12 of 2008 is about constants, but in the example the
type instance is not a constant? The example is fine in ifort (and used in
cosmomc?).
Antony
> -----Original Message-----
> From: vehre at gcc dot gnu.org [mailto:gcc-bugzilla@gcc.gnu.org]
> Sent: 20 March 2015 11:59 AM
> To: antony@cosmologist.info
> Subject: [Bug fortran/61275] Invalid initialization expression for ALLOCATABLE
> component in structure constructor at (1)
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61275
>
> --- Comment #5 from vehre at gcc dot gnu.org ---
> Completely right, the initial test is still not compilable. But this is because
> assigning to an allocatable component in an initializer is not allowed by the
> standards:
> F2003, 7.1.7 (3) and also in
> F2008, 7.1.12 (3).
>
> So the correct code would be:
>
> module A
>
> Type T
> character(LEN=:), allocatable :: S
> end type
> Type(T) :: TestObj = T(NULL())
>
> TestObj%S = 'string'
>
> contains
>
> end module
>
> which compiles and runs w/o error.
> Standard compliant implementation is tested for in
>
> gfortran.dg/alloc_comp_init_expr.f03
>
> only far allocatable arrays, but that's near enough for char arrays for me.
>
> --
> You are receiving this mail because:
> You reported the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/61275] Invalid initialization expression for ALLOCATABLE component in structure constructor at (1)
2014-05-21 16:05 [Bug fortran/61275] New: Invalid initialization expression for ALLOCATABLE component in structure constructor at (1) antony at cosmologist dot info
` (5 preceding siblings ...)
2015-03-20 13:13 ` antony at cosmologist dot info
@ 2015-03-20 13:51 ` vehre at gcc dot gnu.org
2015-03-20 14:57 ` dominiq at lps dot ens.fr
2015-04-17 12:46 ` dominiq at lps dot ens.fr
8 siblings, 0 replies; 10+ messages in thread
From: vehre at gcc dot gnu.org @ 2015-03-20 13:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61275
--- Comment #7 from vehre at gcc dot gnu.org ---
First sentence of F2008, 7.1.12 is:
A constant 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 ...
With Type(T) :: TestObj = T(...) the T after the assign becomes an initializer,
which 7.1.12 states only constant expressions are suitable for. In this
constant expression each structure constructor has to adhere to the conditions
of (3):
a structure constructor where each component-spec corresponding to
(a) an allocatable component is a reference to the intrinsic function
NULL,
(b) ...
Now that S is an allocatable component of T. I think this the only valid
expression for that is NULL() as initializer. This is what gfortran does
currently and this is how I interpret the standard.
Btw, cosmomc compiles fine, so it can't be using this specific construct.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/61275] Invalid initialization expression for ALLOCATABLE component in structure constructor at (1)
2014-05-21 16:05 [Bug fortran/61275] New: Invalid initialization expression for ALLOCATABLE component in structure constructor at (1) antony at cosmologist dot info
` (6 preceding siblings ...)
2015-03-20 13:51 ` vehre at gcc dot gnu.org
@ 2015-03-20 14:57 ` dominiq at lps dot ens.fr
2015-04-17 12:46 ` dominiq at lps dot ens.fr
8 siblings, 0 replies; 10+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-03-20 14:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61275
--- Comment #8 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
module A
Type T
character(LEN=:), allocatable :: S
end type
character(len=6), parameter :: str = 'string'
Type(T) :: TestObj = T(str)
end module
is rejected with
Type(T) :: TestObj = T(str)
1
Error: Invalid initialization expression for ALLOCATABLE component 's' in
structure constructor at (1)
So it seems that
> (a) an allocatable component is a reference to the intrinsic function NULL,
has to be taken in the most restrictive way.
If nobody objects, I'll close the PR as FIXED again.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug fortran/61275] Invalid initialization expression for ALLOCATABLE component in structure constructor at (1)
2014-05-21 16:05 [Bug fortran/61275] New: Invalid initialization expression for ALLOCATABLE component in structure constructor at (1) antony at cosmologist dot info
` (7 preceding siblings ...)
2015-03-20 14:57 ` dominiq at lps dot ens.fr
@ 2015-04-17 12:46 ` dominiq at lps dot ens.fr
8 siblings, 0 replies; 10+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-04-17 12:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61275
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Resolution|--- |FIXED
--- Comment #9 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> If nobody objects, I'll close the PR as FIXED again.
No objection after almost a month. Closing.
^ permalink raw reply [flat|nested] 10+ messages in thread