public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/55932] New: DDT's default structure constructor does not work with having allocatable member variables
@ 2013-01-10  7:59 stefan.mauerberger at gmail dot com
  2013-01-10 10:38 ` [Bug fortran/55932] " dominiq at lps dot ens.fr
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: stefan.mauerberger at gmail dot com @ 2013-01-10  7:59 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55932

             Bug #: 55932
           Summary: DDT's default structure constructor does not work with
                    having allocatable member variables
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: stefan.mauerberger@gmail.com


Created attachment 29138
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29138
minimal working example

Hi Everybody!

First of all, this is my first bug-report. In case I am doing something
inappropriate pleas be soft with me. 

Concerning my problem: 
Invoking the default DDT structure constructor on types with allocatable member
variables causes an internal compiler error. I tried with 4.7.1, 4.7.2 and
4.8.0 20121008. 

Defining a DDT having an allocatable member variable
TYPE :: test_typ
    REAL, ALLOCATABLE :: a
END TYPE
the default structure constructor causes gfortran to crash
my_test_typ = test_typ(a=1.0) 

As far as I can see, my code is valid Fortran. With NAG, PGI and Intel
everything works just fine.

If you need more details pleas let me know.

Cheers, Stefan 

Environment: Ubuntu 12.10
How-To-Repeat: Try to compile the attached code


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/55932] DDT's default structure constructor does not work with having allocatable member variables
  2013-01-10  7:59 [Bug fortran/55932] New: DDT's default structure constructor does not work with having allocatable member variables stefan.mauerberger at gmail dot com
@ 2013-01-10 10:38 ` dominiq at lps dot ens.fr
  2013-01-11 11:50 ` stefan.mauerberger at gmail dot com
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dominiq at lps dot ens.fr @ 2013-01-10 10:38 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55932

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-01-10
                 CC|                            |burnus@net-b.de
     Ever Confirmed|0                           |1

--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2013-01-10 10:38:05 UTC ---
This is a bug with allocatable scalars (the code is rejected with -std=f95).
The code work as expected if I replace 'REAL, ALLOCATABLE :: a' with 'REAL,
ALLOCATABLE :: a(:)' and 'a=1.0' with 'a=[1.0]'.

AFAIK all the allocatable scalar bugs have not yet been fixed and this PR may
be a duplicate of an existing one. Workaround: don't use allocatable scalars if
you can.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/55932] DDT's default structure constructor does not work with having allocatable member variables
  2013-01-10  7:59 [Bug fortran/55932] New: DDT's default structure constructor does not work with having allocatable member variables stefan.mauerberger at gmail dot com
  2013-01-10 10:38 ` [Bug fortran/55932] " dominiq at lps dot ens.fr
@ 2013-01-11 11:50 ` stefan.mauerberger at gmail dot com
  2014-01-05 17:40 ` [Bug fortran/55932] [F03] ICE for structure constructor with scalar allocatable component janus at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: stefan.mauerberger at gmail dot com @ 2013-01-11 11:50 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55932

--- Comment #2 from stefan.mauerberger at gmail dot com 2013-01-11 11:50:19 UTC ---
Indeed, it is a F2003 feature. Does that matter? 

I searched for duplicates without finding a similar one. Anyways ...  

Thanks for the suggested workaround. It seems to work just fine for my pursues.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/55932] [F03] ICE for structure constructor with scalar allocatable component
  2013-01-10  7:59 [Bug fortran/55932] New: DDT's default structure constructor does not work with having allocatable member variables stefan.mauerberger at gmail dot com
  2013-01-10 10:38 ` [Bug fortran/55932] " dominiq at lps dot ens.fr
  2013-01-11 11:50 ` stefan.mauerberger at gmail dot com
@ 2014-01-05 17:40 ` janus at gcc dot gnu.org
  2014-01-05 17:51 ` janus at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2014-01-05 17:40 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55932

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
                 CC|                            |janus at gcc dot gnu.org
            Summary|DDT's default structure     |[F03] ICE for structure
                   |constructor does not work   |constructor with scalar
                   |with having allocatable     |allocatable component
                   |member variables            |

--- Comment #3 from janus at gcc dot gnu.org ---
Slightly compactified test case:

  IMPLICIT NONE 
  TYPE :: test_typ
      REAL, ALLOCATABLE :: a
  END TYPE
  TYPE(test_typ) :: my_test_typ
  my_test_typ = test_typ(1.0)
END


The backtrace with 4.9 trunk is:


internal compiler error: in fold_convert_loc, at fold-const.c:1994
   my_test_typ = test_typ(1.0)
 ^
0x7969df fold_convert_loc(unsigned int, tree_node*, tree_node*)
    /home/jweil/gcc49/trunk/gcc/fold-const.c:1993
0x6429c2 gfc_trans_scalar_assign(gfc_se*, gfc_se*, gfc_typespec, bool, bool,
bool)
    /home/jweil/gcc49/trunk/gcc/fortran/trans-expr.c:6991
0x648b8f gfc_trans_subcomponent_assign
    /home/jweil/gcc49/trunk/gcc/fortran/trans-expr.c:6052
0x648b8f gfc_trans_structure_assign
    /home/jweil/gcc49/trunk/gcc/fortran/trans-expr.c:6099
0x649ad2 gfc_conv_structure(gfc_se*, gfc_expr*, int)
    /home/jweil/gcc49/trunk/gcc/fortran/trans-expr.c:6126
0x64769c gfc_conv_expr(gfc_se*, gfc_expr*)
    /home/jweil/gcc49/trunk/gcc/fortran/trans-expr.c:6285
0x64c0c6 gfc_trans_assignment_1
    /home/jweil/gcc49/trunk/gcc/fortran/trans-expr.c:7946
0x61e795 trans_code
    /home/jweil/gcc49/trunk/gcc/fortran/trans.c:1623
0x63dee2 gfc_generate_function_code(gfc_namespace*)
    /home/jweil/gcc49/trunk/gcc/fortran/trans-decl.c:5605
0x5de510 translate_all_program_units
    /home/jweil/gcc49/trunk/gcc/fortran/parse.c:4536
0x5de510 gfc_parse_file()
    /home/jweil/gcc49/trunk/gcc/fortran/parse.c:4733
0x61adb5 gfc_be_parse_file
    /home/jweil/gcc49/trunk/gcc/fortran/f95-lang.c:188


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/55932] [F03] ICE for structure constructor with scalar allocatable component
  2013-01-10  7:59 [Bug fortran/55932] New: DDT's default structure constructor does not work with having allocatable member variables stefan.mauerberger at gmail dot com
                   ` (2 preceding siblings ...)
  2014-01-05 17:40 ` [Bug fortran/55932] [F03] ICE for structure constructor with scalar allocatable component janus at gcc dot gnu.org
@ 2014-01-05 17:51 ` janus at gcc dot gnu.org
  2014-01-05 18:42 ` janus at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2014-01-05 17:51 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55932

--- Comment #4 from janus at gcc dot gnu.org ---
Allocation-on-assignment works for 'normal' assignments of allocatable scalars,
as shown by this test case:


  IMPLICIT NONE
  TYPE :: test_typ
      REAL, ALLOCATABLE :: a
  END TYPE
  TYPE(test_typ) :: my_test_typ
  my_test_typ%a = 1.
  print *, my_test_typ%a 
END


We just have to make it work for structure constructors.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/55932] [F03] ICE for structure constructor with scalar allocatable component
  2013-01-10  7:59 [Bug fortran/55932] New: DDT's default structure constructor does not work with having allocatable member variables stefan.mauerberger at gmail dot com
                   ` (3 preceding siblings ...)
  2014-01-05 17:51 ` janus at gcc dot gnu.org
@ 2014-01-05 18:42 ` janus at gcc dot gnu.org
  2014-01-09 20:39 ` janus at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2014-01-05 18:42 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55932

--- Comment #5 from janus at gcc dot gnu.org ---
The following is sufficient to get rid of the ICE:

Index: gcc/fortran/trans-expr.c
===================================================================
--- gcc/fortran/trans-expr.c    (revision 206335)
+++ gcc/fortran/trans-expr.c    (working copy)
@@ -6049,6 +6049,8 @@ gfc_trans_subcomponent_assign (tree dest, gfc_comp
       if (cm->ts.type == BT_CHARACTER)
     lse.string_length = cm->ts.u.cl->backend_decl;
       lse.expr = dest;
+      if (cm->attr.allocatable)
+    lse.expr = build_fold_indirect_ref_loc (input_location, lse.expr);
       tmp = gfc_trans_scalar_assign (&lse, &se, cm->ts, true, false, true);
       gfc_add_expr_to_block (&block, tmp);
     }


With this patch, the test case in comment 3 compiles without error. However, it
now segfaults at runtime, because alloc-on-assignment is still missing.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/55932] [F03] ICE for structure constructor with scalar allocatable component
  2013-01-10  7:59 [Bug fortran/55932] New: DDT's default structure constructor does not work with having allocatable member variables stefan.mauerberger at gmail dot com
                   ` (4 preceding siblings ...)
  2014-01-05 18:42 ` janus at gcc dot gnu.org
@ 2014-01-09 20:39 ` janus at gcc dot gnu.org
  2014-01-09 21:49 ` janus at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2014-01-09 20:39 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55932

--- Comment #6 from janus at gcc dot gnu.org ---
(In reply to janus from comment #5)
> The following is sufficient to get rid of the ICE:

Unfortunately it produces several testsuite failures:

alloc_comp_class_1.f90
alloc_comp_class_2.f90
class_19.f03
elemental_optional_args_5.f03
unlimited_polymorphic_8.f90


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/55932] [F03] ICE for structure constructor with scalar allocatable component
  2013-01-10  7:59 [Bug fortran/55932] New: DDT's default structure constructor does not work with having allocatable member variables stefan.mauerberger at gmail dot com
                   ` (5 preceding siblings ...)
  2014-01-09 20:39 ` janus at gcc dot gnu.org
@ 2014-01-09 21:49 ` janus at gcc dot gnu.org
  2014-01-10 14:10 ` janus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2014-01-09 21:49 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55932

--- Comment #7 from janus at gcc dot gnu.org ---
(In reply to janus from comment #6)
> > The following is sufficient to get rid of the ICE:
> 
> Unfortunately it produces several testsuite failures:

All of them are fixed by this version:

Index: gcc/fortran/trans-expr.c
===================================================================
--- gcc/fortran/trans-expr.c    (revision 206462)
+++ gcc/fortran/trans-expr.c    (working copy)
@@ -6049,6 +6049,8 @@ gfc_trans_subcomponent_assign (tree dest, gfc_comp
       if (cm->ts.type == BT_CHARACTER)
     lse.string_length = cm->ts.u.cl->backend_decl;
       lse.expr = dest;
+      if (cm->attr.allocatable && expr->expr_type != EXPR_NULL)
+    lse.expr = build_fold_indirect_ref_loc (input_location, lse.expr);
       tmp = gfc_trans_scalar_assign (&lse, &se, cm->ts, true, false, true);
       gfc_add_expr_to_block (&block, tmp);
     }


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/55932] [F03] ICE for structure constructor with scalar allocatable component
  2013-01-10  7:59 [Bug fortran/55932] New: DDT's default structure constructor does not work with having allocatable member variables stefan.mauerberger at gmail dot com
                   ` (6 preceding siblings ...)
  2014-01-09 21:49 ` janus at gcc dot gnu.org
@ 2014-01-10 14:10 ` janus at gcc dot gnu.org
  2014-01-10 14:13 ` janus at gcc dot gnu.org
  2015-04-17 12:34 ` dominiq at lps dot ens.fr
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2014-01-10 14:10 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55932

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #8 from janus at gcc dot gnu.org ---
*** Bug 57959 has been marked as a duplicate of this bug. ***


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/55932] [F03] ICE for structure constructor with scalar allocatable component
  2013-01-10  7:59 [Bug fortran/55932] New: DDT's default structure constructor does not work with having allocatable member variables stefan.mauerberger at gmail dot com
                   ` (7 preceding siblings ...)
  2014-01-10 14:10 ` janus at gcc dot gnu.org
@ 2014-01-10 14:13 ` janus at gcc dot gnu.org
  2015-04-17 12:34 ` dominiq at lps dot ens.fr
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2014-01-10 14:13 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55932

--- Comment #9 from janus at gcc dot gnu.org ---
(In reply to janus from comment #8)
> *** Bug 57959 has been marked as a duplicate of this bug. ***

carry-over from the above:

Loosely related: PR 49213.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/55932] [F03] ICE for structure constructor with scalar allocatable component
  2013-01-10  7:59 [Bug fortran/55932] New: DDT's default structure constructor does not work with having allocatable member variables stefan.mauerberger at gmail dot com
                   ` (8 preceding siblings ...)
  2014-01-10 14:13 ` janus at gcc dot gnu.org
@ 2015-04-17 12:34 ` dominiq at lps dot ens.fr
  9 siblings, 0 replies; 11+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-04-17 12:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55932

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #11 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
This is fixed on 5.0.1 and trunk (6.0). Closing.


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-04-17 12:34 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-10  7:59 [Bug fortran/55932] New: DDT's default structure constructor does not work with having allocatable member variables stefan.mauerberger at gmail dot com
2013-01-10 10:38 ` [Bug fortran/55932] " dominiq at lps dot ens.fr
2013-01-11 11:50 ` stefan.mauerberger at gmail dot com
2014-01-05 17:40 ` [Bug fortran/55932] [F03] ICE for structure constructor with scalar allocatable component janus at gcc dot gnu.org
2014-01-05 17:51 ` janus at gcc dot gnu.org
2014-01-05 18:42 ` janus at gcc dot gnu.org
2014-01-09 20:39 ` janus at gcc dot gnu.org
2014-01-09 21:49 ` janus at gcc dot gnu.org
2014-01-10 14:10 ` janus at gcc dot gnu.org
2014-01-10 14:13 ` janus at gcc dot gnu.org
2015-04-17 12:34 ` dominiq at lps dot ens.fr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).