public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patc, fortran] PR85603 - ICE with character array substring assignment
@ 2018-09-22 13:23 Paul Richard Thomas
  2018-10-18 17:05 ` Paul Richard Thomas
  0 siblings, 1 reply; 7+ messages in thread
From: Paul Richard Thomas @ 2018-09-22 13:23 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 437 bytes --]

Yet another 'obvious' deferred character fix. Committed to trunk as
r264502. Will backport in about ten days time.

Paul

2018-09-22  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/85603
    * trans-array.c (gfc_alloc_allocatable_for_assignment): Test
    the charlen backend_decl before using the VAR_P macro.

2018-09-22  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/85603
    * gfortran.dg/deferred_character_23.f90 : New test.

[-- Attachment #2: submit.diff --]
[-- Type: text/x-patch, Size: 1589 bytes --]

Index: gcc/fortran/trans-array.c
===================================================================
*** gcc/fortran/trans-array.c	(revision 264486)
--- gcc/fortran/trans-array.c	(working copy)
*************** gfc_alloc_allocatable_for_assignment (gf
*** 9950,9956 ****
      {
        if (expr2->ts.deferred)
  	{
! 	  if (VAR_P (expr2->ts.u.cl->backend_decl))
  	    tmp = expr2->ts.u.cl->backend_decl;
  	  else
  	    tmp = rss->info->string_length;
--- 9950,9957 ----
      {
        if (expr2->ts.deferred)
  	{
! 	  if (expr2->ts.u.cl->backend_decl
! 	      && VAR_P (expr2->ts.u.cl->backend_decl))
  	    tmp = expr2->ts.u.cl->backend_decl;
  	  else
  	    tmp = rss->info->string_length;
Index: gcc/testsuite/gfortran.dg/deferred_character_23.f90
===================================================================
*** gcc/testsuite/gfortran.dg/deferred_character_23.f90	(nonexistent)
--- gcc/testsuite/gfortran.dg/deferred_character_23.f90	(working copy)
***************
*** 0 ****
--- 1,22 ----
+ ! { dg-do run }
+ !
+ ! Tests the fix for PR85603.
+ !
+ ! Contributed by Walt Spector  <w6ws@earthlink.net>
+ !
+ program strlen_bug
+   implicit none
+ 
+   character(:), allocatable :: strings(:)
+   integer :: maxlen
+ 
+   strings = [ character(32) ::  &
+       'short',  &
+       'somewhat longer' ]
+   maxlen = maxval (len_trim (strings))
+   if (maxlen .ne. 15) stop 1
+   strings = strings(:)(:maxlen) ! Used to ICE
+   if (any (strings .ne. ['short          ','somewhat longer'])) stop 2
+ 
+   deallocate (strings)          ! To check for memory leaks
+ end program

^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: [Patc, fortran] PR85603 - ICE with character array substring assignment
@ 2018-10-19 21:52 Dominique d'Humières
  2018-10-19 23:36 ` Dominique d'Humières
  0 siblings, 1 reply; 7+ messages in thread
From: Dominique d'Humières @ 2018-10-19 21:52 UTC (permalink / raw)
  To: Paul Richard Thomas; +Cc: gfortran, gcc-patches

Hi Paul,

I get a regression with your patch:

obfuscated_tn4.f90:300:0:

  300 |     TP6%ROR=TP6%ROR(:PP4-1)
      | 
internal compiler error: in gfc_trans_deferred_vars, at fortran/trans-decl.c:4754


I’ll try to reduce the test.

Dominique

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

end of thread, other threads:[~2018-10-21 10:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-22 13:23 [Patc, fortran] PR85603 - ICE with character array substring assignment Paul Richard Thomas
2018-10-18 17:05 ` Paul Richard Thomas
2018-10-19 21:52 Dominique d'Humières
2018-10-19 23:36 ` Dominique d'Humières
2018-10-20 15:47   ` Paul Richard Thomas
2018-10-20 16:53     ` Paul Richard Thomas
2018-10-21 16:07       ` Thomas Koenig

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).