[Bug fortran/82367] ICE with deferred length string allocate on non-deferred length argument

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

kargl at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED
   Target Milestone|--- |6.5

--- Comment #8 from kargl at gcc dot gnu.org ---
Fixed on 6-branch, 7-branch, and trunk.
Thanks for the bug report.

[Bug fortran/82367] ICE with deferred length string allocate on non-deferred length argument

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

--- Comment #7 from kargl at gcc dot gnu.org ---
Author: kargl
Date: Wed Jan 10 23:55:00 2018
New Revision: 256467

URL: https://gcc.gnu.org/viewcvs?rev=256467=gcc=rev
Log:
2018-01-10  Steven G. Kargl  

PR fortran/82367
* resolve.c (resolve_allocate_expr): Check for NULL pointer.

2018-01-10  Steven G. Kargl  

PR fortran/82367
* gfortran.dg/deferred_character_18.f90: New test.

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

[Bug fortran/82367] ICE with deferred length string allocate on non-deferred length argument

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

--- Comment #6 from kargl at gcc dot gnu.org ---
Author: kargl
Date: Wed Jan 10 23:41:48 2018
New Revision: 256466

URL: https://gcc.gnu.org/viewcvs?rev=256466=gcc=rev
Log:
2018-01-10  Steven G. Kargl  

PR fortran/82367
* resolve.c (resolve_allocate_expr): Check for NULL pointer.

2018-01-10  Steven G. Kargl  

PR fortran/82367
* gfortran.dg/deferred_character_18.f90: New test.

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

[Bug fortran/82367] ICE with deferred length string allocate on non-deferred length argument

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

--- Comment #5 from kargl at gcc dot gnu.org ---
Author: kargl
Date: Wed Jan 10 23:26:15 2018
New Revision: 256464

URL: https://gcc.gnu.org/viewcvs?rev=256464=gcc=rev
Log:
2018-01-10  Steven G. Kargl  

PR fortran/82367
* resolve.c (resolve_allocate_expr): Check for NULL pointer.

2018-01-10  Steven G. Kargl  

PR fortran/82367
* gfortran.dg/deferred_character_18.f90: New test.

Added:
trunk/gcc/testsuite/gfortran.dg/deferred_character_18.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/resolve.c
trunk/gcc/testsuite/ChangeLog

[Bug fortran/82367] ICE with deferred length string allocate on non-deferred length argument

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

kargl at gcc dot gnu.org changed:

   What|Removed |Added

   Priority|P3  |P4
 CC||kargl at gcc dot gnu.org
   Assignee|unassigned at gcc dot gnu.org  |kargl at gcc dot gnu.org

[Bug fortran/82367] ICE with deferred length string allocate on non-deferred length argument

2017-12-01 Thread tkoenig at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82367

Thomas Koenig  changed:

   What|Removed |Added

 CC||tkoenig at gcc dot gnu.org

--- Comment #4 from Thomas Koenig  ---
(In reply to kargl from comment #3)
> % svn diff resolve.c 
> Index: resolve.c
> ===
> --- resolve.c   (revision 253236)
> +++ resolve.c   (working copy)
> @@ -7387,8 +7387,14 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code, bo
>if (code->ext.alloc.ts.type == BT_CHARACTER && !e->ts.deferred
>&& !UNLIMITED_POLY (e))
>  {
> -  int cmp = gfc_dep_compare_expr (e->ts.u.cl->length,
> - code->ext.alloc.ts.u.cl->length);
> +  int cmp;
> +
> +  if (!e->ts.u.cl->length)
> +   goto failure;
> +
> +  cmp = gfc_dep_compare_expr (e->ts.u.cl->length,
> + code->ext.alloc.ts.u.cl->length);
> +
>if (cmp == 1 || cmp == -1 || cmp == -3)
> {
>   gfc_error ("Allocating %s at %L with type-spec requires the same "

Looks good (and obvious, too).  Pre-approved.

[Bug fortran/82367] ICE with deferred length string allocate on non-deferred length argument

2017-09-29 Thread kargl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82367

--- Comment #3 from kargl at gcc dot gnu.org ---
% svn diff resolve.c 
Index: resolve.c
===
--- resolve.c   (revision 253236)
+++ resolve.c   (working copy)
@@ -7387,8 +7387,14 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code, bo
   if (code->ext.alloc.ts.type == BT_CHARACTER && !e->ts.deferred
   && !UNLIMITED_POLY (e))
 {
-  int cmp = gfc_dep_compare_expr (e->ts.u.cl->length,
- code->ext.alloc.ts.u.cl->length);
+  int cmp;
+
+  if (!e->ts.u.cl->length)
+   goto failure;
+
+  cmp = gfc_dep_compare_expr (e->ts.u.cl->length,
+ code->ext.alloc.ts.u.cl->length);
+
   if (cmp == 1 || cmp == -1 || cmp == -3)
{
  gfc_error ("Allocating %s at %L with type-spec requires the same "

[Bug fortran/82367] ICE with deferred length string allocate on non-deferred length argument

2017-09-29 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82367

Dominique d'Humieres  changed:

   What|Removed |Added

   Keywords||ice-on-invalid-code
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2017-09-29
 CC||pault at gcc dot gnu.org
 Blocks||68241
 Ever confirmed|0   |1

--- Comment #2 from Dominique d'Humieres  ---
ICE confirmed from 4.8 up to trunk.

Compiling the test with my instrumented gfortran gives

../../work/gcc/fortran/dependency.c:321:11: runtime error: member access within
null pointer of type 'struct gfc_expr'
ASAN:DEADLYSIGNAL
=
==15952==ERROR: AddressSanitizer: SEGV on unknown address 0x (pc
0x0001003d484b bp 0x7fff5fbfe4b0 sp 0x7fff5fbfe490 T0)
==15952==The signal is caused by a READ memory access.
==15952==Hint: address points to the zero page.
#0 0x1003d484a in gfc_dep_compare_expr(gfc_expr*, gfc_expr*)
(/opt/gcc/gcc8g/libexec/gcc/x86_64-apple-darwin16.7.0/8.0.0/f951+0x1003d484a)
#1 0x100337829 in resolve_allocate_expr(gfc_expr*, gfc_code*, bool*)
(/opt/gcc/gcc8g/libexec/gcc/x86_64-apple-darwin16.7.0/8.0.0/f951+0x100337829)
#2 0x10033f34d in resolve_allocate_deallocate(gfc_code*, char const*)
(/opt/gcc/gcc8g/libexec/gcc/x86_64-apple-darwin16.7.0/8.0.0/f951+0x10033f34d)
#3 0x1003535ee in gfc_resolve_code(gfc_code*, gfc_namespace*)
(/opt/gcc/gcc8g/libexec/gcc/x86_64-apple-darwin16.7.0/8.0.0/f951+0x1003535ee)
#4 0x100355d83 in resolve_codes(gfc_namespace*)
(/opt/gcc/gcc8g/libexec/gcc/x86_64-apple-darwin16.7.0/8.0.0/f951+0x100355d83)
#5 0x100355b2b in resolve_codes(gfc_namespace*)
(/opt/gcc/gcc8g/libexec/gcc/x86_64-apple-darwin16.7.0/8.0.0/f951+0x100355b2b)
#6 0x1002f42e1 in gfc_resolve(gfc_namespace*)
(/opt/gcc/gcc8g/libexec/gcc/x86_64-apple-darwin16.7.0/8.0.0/f951+0x1002f42e1)
#7 0x10029a2bf in gfc_parse_file()
(/opt/gcc/gcc8g/libexec/gcc/x86_64-apple-darwin16.7.0/8.0.0/f951+0x10029a2bf)
#8 0x1003f14f2 in gfc_be_parse_file()
(/opt/gcc/gcc8g/libexec/gcc/x86_64-apple-darwin16.7.0/8.0.0/f951+0x1003f14f2)
#9 0x1045a4bac in compile_file()
(/opt/gcc/gcc8g/libexec/gcc/x86_64-apple-darwin16.7.0/8.0.0/f951+0x1045a4bac)
#10 0x1045ad7fe in do_compile()
(/opt/gcc/gcc8g/libexec/gcc/x86_64-apple-darwin16.7.0/8.0.0/f951+0x1045ad7fe)
#11 0x10651f30d in toplev::main(int, char**)
(/opt/gcc/gcc8g/libexec/gcc/x86_64-apple-darwin16.7.0/8.0.0/f951+0x10651f30d)
#12 0x1065249ce in main
(/opt/gcc/gcc8g/libexec/gcc/x86_64-apple-darwin16.7.0/8.0.0/f951+0x1065249ce)
#13 0x7fffbcb65234 in start (/usr/lib/system/libdyld.dylib+0x5234)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV
(/opt/gcc/gcc8g/libexec/gcc/x86_64-apple-darwin16.7.0/8.0.0/f951+0x1003d484a)
in gfc_dep_compare_expr(gfc_expr*, gfc_expr*)
8820864)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
f951: internal compiler error: Abort trap: 6


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68241
[Bug 68241] [meta-bug] [F03] Deferred-length character

[Bug fortran/82367] ICE with deferred length string allocate on non-deferred length argument

2017-09-29 Thread w6ws at earthlink dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82367

--- Comment #1 from Walter Spector  ---
PGI and NAG both catch this error.  I can try Intel if needed.