[Bug fortran/60450] [4.7/4.8 Regression] ICE with SHAPE intrinsic

2014-03-09 Thread dave.allured at noaa dot gov
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60450

--- Comment #13 from Dave Allured  ---
(In reply to janus from comment #11)
> (In reply to Dave Allured from comment #9) 
> > Janus, are you sure that the release branch of 4.7 really needs a fix?  My
> > test shows that the latest release, 4.7.3, passes this test case, but you
> > said "4.7" failed for you.
> 
> Actually I tested the current state of the 4.7 branch, i.e. post-4.7.3, and
> yes, in fact this fails.
> 
> It seems that the problem was only introduced after the 4.7.3 release,
> namely in r198690.
> 
> I have just committed the fix to the 4.7 branch as r208443.

Okay, that's great to have the discrepancy explained.  Thanks again Janus.


[Bug fortran/60450] [4.7/4.8 Regression] ICE with SHAPE intrinsic

2014-03-09 Thread janus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60450

janus at gcc dot gnu.org changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #12 from janus at gcc dot gnu.org ---
The bug has been fixed for the upcoming releases 4.8.3 and 4.7.4. Closing.
Thanks for the report!


[Bug fortran/60450] [4.7/4.8 Regression] ICE with SHAPE intrinsic

2014-03-09 Thread janus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60450

--- Comment #10 from janus at gcc dot gnu.org ---
Author: janus
Date: Sun Mar  9 18:44:42 2014
New Revision: 208443

URL: http://gcc.gnu.org/viewcvs?rev=208443&root=gcc&view=rev
Log:
2014-03-09  Janus Weil  

Backport from 4.8
2014-03-08  Janus Weil  

PR fortran/60450
* simplify.c (gfc_simplify_shape): Only clear shape if it was really
created successfully.


2014-03-09  Janus Weil  

Backport from 4.8
2014-03-08  Janus Weil  

PR fortran/60450
* gfortran.dg/shape_8.f90: New.

Added:
branches/gcc-4_7-branch/gcc/testsuite/gfortran.dg/shape_8.f90
Modified:
branches/gcc-4_7-branch/gcc/fortran/ChangeLog
branches/gcc-4_7-branch/gcc/fortran/simplify.c
branches/gcc-4_7-branch/gcc/testsuite/ChangeLog


[Bug fortran/60450] [4.7/4.8 Regression] ICE with SHAPE intrinsic

2014-03-09 Thread janus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60450

--- Comment #11 from janus at gcc dot gnu.org ---
(In reply to Dave Allured from comment #9) 
> Janus, are you sure that the release branch of 4.7 really needs a fix?  My
> test shows that the latest release, 4.7.3, passes this test case, but you
> said "4.7" failed for you.

Actually I tested the current state of the 4.7 branch, i.e. post-4.7.3, and
yes, in fact this fails.

It seems that the problem was only introduced after the 4.7.3 release, namely
in r198690.

I have just committed the fix to the 4.7 branch as r208443.


[Bug fortran/60450] [4.7/4.8 Regression] ICE with SHAPE intrinsic

2014-03-09 Thread dave.allured at noaa dot gov
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60450

--- Comment #9 from Dave Allured  ---
(In reply to janus from comment #8)
> 
> Thanks, committed to the 4.8 branch as r208430. Will backport to 4.7 soon.

Janus, are you sure that the release branch of 4.7 really needs a fix?  My test
shows that the latest release, 4.7.3, passes this test case, but you said "4.7"
failed for you.

I just reconfirmed this with the Mac Ports distribution version of 4.7.3
(x86-64 target, Mac OS).  I recall that my IT staff got the same positive
result for 4.7.3 on Linux, but I can't confirm that on the weekend.

mac56:~/gfortran/bugs/shape-bug 14> gfortran-mp-4.7 --version | grep gcc
GNU Fortran (MacPorts gcc47 4.7.3_3) 4.7.3

mac56:~/gfortran/bugs/shape-bug 15> gfortran-mp-4.7 -Wall -Wextra
shape-reduced.f90 

mac56:~/gfortran/bugs/shape-bug 16> cat shape-reduced.f90 
  real, allocatable :: x(:,:)
  allocate (x(3,2),source=99.)
  print *, shape (x / 10.0)
end

mac56:~/gfortran/bugs/shape-bug 17> ./a.out
   3   2


[Bug fortran/60450] [4.7/4.8 Regression] ICE with SHAPE intrinsic

2014-03-08 Thread janus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60450

--- Comment #8 from janus at gcc dot gnu.org ---
(In reply to kargl from comment #6)
> Patch is OK with a testcase.

Thanks, committed to the 4.8 branch as r208430. Will backport to 4.7 soon.


[Bug fortran/60450] [4.7/4.8 Regression] ICE with SHAPE intrinsic

2014-03-08 Thread janus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60450

--- Comment #7 from janus at gcc dot gnu.org ---
Author: janus
Date: Sat Mar  8 13:59:00 2014
New Revision: 208430

URL: http://gcc.gnu.org/viewcvs?rev=208430&root=gcc&view=rev
Log:
2014-03-08  Janus Weil  

PR fortran/60450
* simplify.c (gfc_simplify_shape): Only clear shape if it was really
created successfully.


2014-03-08  Janus Weil  

PR fortran/60450
* gfortran.dg/shape_8.f90: New.

Added:
branches/gcc-4_8-branch/gcc/testsuite/gfortran.dg/shape_8.f90
Modified:
branches/gcc-4_8-branch/gcc/fortran/ChangeLog
branches/gcc-4_8-branch/gcc/fortran/simplify.c
branches/gcc-4_8-branch/gcc/testsuite/ChangeLog


[Bug fortran/60450] [4.7/4.8 Regression] ICE with SHAPE intrinsic

2014-03-07 Thread kargl at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60450

kargl at gcc dot gnu.org changed:

   What|Removed |Added

 CC||kargl at gcc dot gnu.org

--- Comment #6 from kargl at gcc dot gnu.org ---
(In reply to janus from comment #4)
> (In reply to janus from comment #3)
> > The following patch is sufficient to fix it on 4.8:
> 
> ... and regtests cleanly.

Patch is OK with a testcase.


[Bug fortran/60450] [4.7/4.8 Regression] ICE with SHAPE intrinsic

2014-03-07 Thread dave.allured at noaa dot gov
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60450

--- Comment #5 from Dave Allured  ---
Janus, thank you!

--Dave


[Bug fortran/60450] [4.7/4.8 Regression] ICE with SHAPE intrinsic

2014-03-07 Thread janus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60450

--- Comment #4 from janus at gcc dot gnu.org ---
(In reply to janus from comment #3)
> The following patch is sufficient to fix it on 4.8:

... and regtests cleanly.


[Bug fortran/60450] [4.7/4.8 Regression] ICE with SHAPE intrinsic

2014-03-07 Thread janus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60450

janus at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |janus at gcc dot gnu.org

--- Comment #3 from janus at gcc dot gnu.org ---
The following patch is sufficient to fix it on 4.8:


Index: gcc/fortran/simplify.c
===
--- gcc/fortran/simplify.c(revision 208401)
+++ gcc/fortran/simplify.c(working copy)
@@ -5528,7 +5528,7 @@ gfc_simplify_shape (gfc_expr *source, gfc_expr *ki
   if (e == &gfc_bad_expr || range_check (e, "SHAPE") == &gfc_bad_expr)
 {
   gfc_free_expr (result);
-  if (t)
+  if (t == SUCCESS)
 gfc_clear_shape (shape, source->rank);
   return &gfc_bad_expr;
 }
@@ -5536,7 +5536,7 @@ gfc_simplify_shape (gfc_expr *source, gfc_expr *ki
   gfc_constructor_append_expr (&result->value.constructor, e, NULL);
 }

-  if (t)
+  if (t == SUCCESS)
 gfc_clear_shape (shape, source->rank);

   return result;


On trunk, 't' was changed from 'gfc_try' to bool in r197682, which also fixed
the problem.


[Bug fortran/60450] [4.7/4.8 Regression] ICE with SHAPE intrinsic

2014-03-07 Thread janus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60450

--- Comment #2 from janus at gcc dot gnu.org ---
Slightly reduced test case:

  real, allocatable :: x(:,:)
  allocate (x(3,2),source=99.)
  print *, shape (x / 10.0)
end


Still works with 4.6 and trunk, but ICEs with 4.7 and 4.8.


[Bug fortran/60450] [4.7/4.8 Regression] ICE with SHAPE intrinsic

2014-03-07 Thread janus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60450

janus at gcc dot gnu.org changed:

   What|Removed |Added

   Keywords||ice-on-valid-code
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2014-03-07
 CC||janus at gcc dot gnu.org
Summary|ICE with SHAPE intrinsic|[4.7/4.8 Regression] ICE
   ||with SHAPE intrinsic
 Ever confirmed|0   |1

--- Comment #1 from janus at gcc dot gnu.org ---
The test case compiles cleanly here with 4.4 and 4.6, then I get segfaults with
4.7 and 4.8 and it works again with trunk.


With a current 4.8 branch build I get this backtrace:

f951: internal compiler error: Segmentation fault
0x8a96af crash_signal
/home/jweil/gcc48/branch/gcc/toplev.c:332
0x547d8b gfc_clear_shape(__mpz_struct (*) [1], int)
/home/jweil/gcc48/branch/gcc/fortran/expr.c:405
0x5b5d70 gfc_simplify_shape(gfc_expr*, gfc_expr*)
/home/jweil/gcc48/branch/gcc/fortran/simplify.c:5540
0x5567d1 do_simplify
/home/jweil/gcc48/branch/gcc/fortran/intrinsic.c:3810
0x563e66 gfc_intrinsic_func_interface(gfc_expr*, int)
/home/jweil/gcc48/branch/gcc/fortran/intrinsic.c:4160
0x59fe51 resolve_unknown_f
/home/jweil/gcc48/branch/gcc/fortran/resolve.c:2602
0x59fe51 resolve_function
/home/jweil/gcc48/branch/gcc/fortran/resolve.c:3204
0x59fe51 gfc_resolve_expr(gfc_expr*)
/home/jweil/gcc48/branch/gcc/fortran/resolve.c:6544
0x5a66e1 resolve_code
/home/jweil/gcc48/branch/gcc/fortran/resolve.c:10208
0x5a8b8e resolve_codes
/home/jweil/gcc48/branch/gcc/fortran/resolve.c:15061
0x599562 gfc_resolve
/home/jweil/gcc48/branch/gcc/fortran/resolve.c:15089
0x58dda2 resolve_all_program_units
/home/jweil/gcc48/branch/gcc/fortran/parse.c:4406
0x58dda2 gfc_parse_file()
/home/jweil/gcc48/branch/gcc/fortran/parse.c:4673
0x5c9de5 gfc_be_parse_file
/home/jweil/gcc48/branch/gcc/fortran/f95-lang.c:189