[Bug fortran/83874] [6/7/8 Regression] ICE initializing character array from derived type

2018-01-15 Thread anlauf at gmx dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83874

--- Comment #1 from Harald Anlauf  ---
1719  else if (init->expr_type == EXPR_ARRAY)
1720{
1721  if (init->ts.u.cl)
1722{
1723  const gfc_expr *length =
init->ts.u.cl->length;
1724  if (length->expr_type != EXPR_CONSTANT)

Length is null here, so dereferencing fails.

[Bug fortran/83874] [6/7/8 Regression] ICE initializing character array from derived type

2018-01-16 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83874

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P4
   Target Milestone|--- |6.5

[Bug fortran/83874] [6/7/8 Regression] ICE initializing character array from derived type

2018-01-16 Thread gs...@t-online.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83874

G. Steinmetz  changed:

   What|Removed |Added

 CC||gs...@t-online.de

--- Comment #2 from G. Steinmetz  ---
Reproducible, and thematically related to pr71203.

[Bug fortran/83874] [6/7/8 Regression] ICE initializing character array from derived type

2018-01-17 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83874

Dominique d'Humieres  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2018-01-17
 Ever confirmed|0   |1
  Known to fail||5.5.0

--- Comment #3 from Dominique d'Humieres  ---
Likely revision r222342 for gcc-6 and r222343 for gcc-5.

[Bug fortran/83874] [6/7/8 Regression] ICE initializing character array from derived type

2018-01-17 Thread anlauf at gmx dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83874

--- Comment #4 from Harald Anlauf  ---
The following obvious patch fixes the ICE:

Index: gcc/fortran/decl.c
===
--- gcc/fortran/decl.c  (revision 256671)
+++ gcc/fortran/decl.c  (working copy)
@@ -1718,7 +1718,7 @@
}
  else if (init->expr_type == EXPR_ARRAY)
{
- if (init->ts.u.cl)
+ if (init->ts.u.cl && init->ts.u.cl->length)
{
  const gfc_expr *length = init->ts.u.cl->length;
  if (length->expr_type != EXPR_CONSTANT)

Needs regtesting, though.

[Bug fortran/83874] [6/7/8 Regression] ICE initializing character array from derived type

2018-01-17 Thread anlauf at gmx dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83874

--- Comment #5 from Harald Anlauf  ---
Regtested without new failures on i686-pc-linux-gnu.

Will submit patch with testcase.

[Bug fortran/83874] [6/7/8 Regression] ICE initializing character array from derived type

2018-01-17 Thread anlauf at gmx dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83874

--- Comment #6 from Harald Anlauf  ---
Patch submitted:

https://gcc.gnu.org/ml/gcc-patches/2018-01/msg01600.html

[Bug fortran/83874] [6/7/8 Regression] ICE initializing character array from derived type

2018-01-17 Thread kargl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83874

--- Comment #7 from kargl at gcc dot gnu.org ---
Author: kargl
Date: Wed Jan 17 23:50:02 2018
New Revision: 256824

URL: https://gcc.gnu.org/viewcvs?rev=256824&root=gcc&view=rev
Log:
2018-01-17  Harald Anlauf  

PR fortran/83874
* decl.c (add_init_expr_to_sym): Do not dereference NULL pointer.


2018-01-17  Harald Anlauf  

PR fortran/83874
* gfortran.dg/pr83874.f90: New test.

Added:
trunk/gcc/testsuite/gfortran.dg/pr83874.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/decl.c
trunk/gcc/testsuite/ChangeLog

[Bug fortran/83874] [6/7/8 Regression] ICE initializing character array from derived type

2018-01-17 Thread kargl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83874

--- Comment #8 from kargl at gcc dot gnu.org ---
Author: kargl
Date: Thu Jan 18 00:30:42 2018
New Revision: 256829

URL: https://gcc.gnu.org/viewcvs?rev=256829&root=gcc&view=rev
Log:
2018-01-17  Harald Anlauf  

Backport from mainline
PR fortran/83874
* decl.c (add_init_expr_to_sym): Do not dereference NULL pointer.

2018-01-17  Harald Anlauf  

Backport from mainline
PR fortran/83874
* gfortran.dg/pr83874.f90: New test.

Added:
branches/gcc-7-branch/gcc/testsuite/gfortran.dg/pr83874.f90
Modified:
branches/gcc-7-branch/gcc/fortran/ChangeLog
branches/gcc-7-branch/gcc/fortran/decl.c
branches/gcc-7-branch/gcc/testsuite/ChangeLog

[Bug fortran/83874] [6/7/8 Regression] ICE initializing character array from derived type

2018-01-17 Thread kargl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83874

--- Comment #9 from kargl at gcc dot gnu.org ---
Author: kargl
Date: Thu Jan 18 01:04:36 2018
New Revision: 256830

URL: https://gcc.gnu.org/viewcvs?rev=256830&root=gcc&view=rev
Log:
2018-01-17  Harald Anlauf  

Back from mainline
PR fortran/83874
* decl.c (add_init_expr_to_sym): Do not dereference NULL pointer.

2018-01-17  Harald Anlauf  

Back from mainline
PR fortran/83874
* gfortran.dg/pr83874.f90: New test.

Added:
branches/gcc-6-branch/gcc/testsuite/gfortran.dg/pr83874.f90
Modified:
branches/gcc-6-branch/gcc/fortran/ChangeLog
branches/gcc-6-branch/gcc/fortran/decl.c
branches/gcc-6-branch/gcc/testsuite/ChangeLog

[Bug fortran/83874] [6/7/8 Regression] ICE initializing character array from derived type

2018-01-18 Thread anlauf at gmx dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83874

Harald Anlauf  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #10 from Harald Anlauf  ---
Steve,
thanks for committing and the backports to 7 and 6.