public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/32880]  New: User operator & allocatable TYPE components: wrong deallocate
@ 2007-07-24 15:56 burnus at gcc dot gnu dot org
  2007-07-24 16:20 ` [Bug fortran/32880] " burnus at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-07-24 15:56 UTC (permalink / raw)
  To: gcc-bugs

The following program comes - as PR 32842 - from Lawrie Schonfeld's
ISO_VARYING_STRING testsuite. Note this bug remains after the patch for PR
32842 has been applied.

The dump shows:

  _gfortran_deallocate (res.chars.data
  op_assign_vs_ch (&res, (char[1:10] *) &char_a[5]{lb: 1 sz: 1}, 1);
  _gfortran_deallocate (res.chars.data
  res = op_concat_vs_ch (&res, (char[1:10] *) &char_a[5]{lb: 1 sz: 1}, 1);

The second deallocate is wrong.

(If you don't have an ISO_VARYING_STRING, you can get it from:
http://www.fortran.com/iso_varying_string.f95 )

program VST28 ! (C) copyright J.L.Schonfelder 1998
  use ISO_VARYING_STRING
  character(len=10) :: char_a
  type(VARYING_STRING) :: res
  char_a = "1234567890"
  res = char_a(5:5)
  res = res//char_a(5:5)
!  if(char(res) /= "55") then
!write(*,'(a,''"'',a,''", '',i0)') 'ERROR:Expect "55", got:',char(res),len(res)
!  end if
end program VST28


-- 
           Summary: User operator & allocatable TYPE components: wrong
                    deallocate
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


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


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

* [Bug fortran/32880] User operator & allocatable TYPE components: wrong deallocate
  2007-07-24 15:56 [Bug fortran/32880] New: User operator & allocatable TYPE components: wrong deallocate burnus at gcc dot gnu dot org
@ 2007-07-24 16:20 ` burnus at gcc dot gnu dot org
  2007-07-24 19:57 ` pault at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-07-24 16:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from burnus at gcc dot gnu dot org  2007-07-24 16:20 -------
Created an attachment (id=13961)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13961&action=view)
Reduced test case

Reduced test case which does not depend anymore on external files.
Coredumps with gfortran, works with NAG f95 and g95.


-- 


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


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

* [Bug fortran/32880] User operator & allocatable TYPE components: wrong deallocate
  2007-07-24 15:56 [Bug fortran/32880] New: User operator & allocatable TYPE components: wrong deallocate burnus at gcc dot gnu dot org
  2007-07-24 16:20 ` [Bug fortran/32880] " burnus at gcc dot gnu dot org
@ 2007-07-24 19:57 ` pault at gcc dot gnu dot org
  2007-07-25  5:20 ` pault at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-07-24 19:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pault at gcc dot gnu dot org  2007-07-24 19:57 -------
Tobias,

Well done - that's a useful reduction.

I don't think that the deallocate is entirely wrong.  However, the the rhs
expression should be assigned to a temporary first, the result deallocating and
the assignement completing.

Paul


-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-07-24 19:57:43
               date|                            |


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


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

* [Bug fortran/32880] User operator & allocatable TYPE components: wrong deallocate
  2007-07-24 15:56 [Bug fortran/32880] New: User operator & allocatable TYPE components: wrong deallocate burnus at gcc dot gnu dot org
  2007-07-24 16:20 ` [Bug fortran/32880] " burnus at gcc dot gnu dot org
  2007-07-24 19:57 ` pault at gcc dot gnu dot org
@ 2007-07-25  5:20 ` pault at gcc dot gnu dot org
  2007-07-27 17:35 ` patchapp at dberlin dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-07-25  5:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pault at gcc dot gnu dot org  2007-07-25 05:20 -------
Another sub-pr: putting the res on the rhs in parentheses does not work either.
 This can be fixed by...

$ svn diff -x -cp gcc/fortran/trans-expr.c
Index: gcc/fortran/trans-expr.c
===================================================================
*** gcc/fortran/trans-expr.c    (revision 126885)
--- gcc/fortran/trans-expr.c    (working copy)
*************** gfc_conv_variable (gfc_se * se, gfc_expr
*** 472,477 ****
--- 472,482 ----
                  || sym->attr.result))
            se->expr = build_fold_indirect_ref (se->expr);

+         /* A character with VALUE attribute needs an address
+            expression.  */
+         if (sym->attr.value)
+           se->expr = build_fold_addr_expr (se->expr);
+
        }
        else if (!sym->attr.value)
        {
*************** gfc_conv_expr_op (gfc_se * se, gfc_expr
*** 1044,1049 ****
--- 1049,1064 ----
      case INTRINSIC_UPLUS:
      case INTRINSIC_PARENTHESES:
        gfc_conv_expr (se, expr->value.op.op1);
+
+       if (expr->value.op.op1->ts.type == BT_DERIVED
+           && expr->value.op.op1->ts.derived->attr.alloc_comp)
+       {
+         tmp = gfc_evaluate_now (se->expr, &se->pre);
+         type = gfc_copy_alloc_comp (expr->value.op.op1->ts.derived, se->expr,
tmp, 0);
+         se->expr = tmp;
+         gfc_add_expr_to_block (&se->pre, type);
+       }
+
        return;

leading to a dependency check which puts res in parentheses for the primary
problem.

Paul


-- 


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


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

* [Bug fortran/32880] User operator & allocatable TYPE components: wrong deallocate
  2007-07-24 15:56 [Bug fortran/32880] New: User operator & allocatable TYPE components: wrong deallocate burnus at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2007-07-25  5:20 ` pault at gcc dot gnu dot org
@ 2007-07-27 17:35 ` patchapp at dberlin dot org
  2007-07-28  5:29 ` pault at gcc dot gnu dot org
  2007-07-28  5:30 ` pault at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: patchapp at dberlin dot org @ 2007-07-27 17:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from patchapp at dberlin dot org  2007-07-27 17:35 -------
Subject: Bug number PR32880

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2007-07/msg01998.html


-- 


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


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

* [Bug fortran/32880] User operator & allocatable TYPE components: wrong deallocate
  2007-07-24 15:56 [Bug fortran/32880] New: User operator & allocatable TYPE components: wrong deallocate burnus at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2007-07-27 17:35 ` patchapp at dberlin dot org
@ 2007-07-28  5:29 ` pault at gcc dot gnu dot org
  2007-07-28  5:30 ` pault at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-07-28  5:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pault at gcc dot gnu dot org  2007-07-28 05:29 -------
Subject: Bug 32880

Author: pault
Date: Sat Jul 28 05:29:06 2007
New Revision: 127011

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=127011
Log:
2007-07-28  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/32880
        * trans-expr.c (gfc_trans_scalar_assign): Revert to fixed order
        for lse and rse pre expressions, for derived types with
        allocatable components.  Instead, assign the lhs to a temporary
        and deallocate after the assignment.

2007-07-28  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/32880
        * gfortran.dg/alloc_comp_assign_6.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/alloc_comp_assign_6.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug fortran/32880] User operator & allocatable TYPE components: wrong deallocate
  2007-07-24 15:56 [Bug fortran/32880] New: User operator & allocatable TYPE components: wrong deallocate burnus at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2007-07-28  5:29 ` pault at gcc dot gnu dot org
@ 2007-07-28  5:30 ` pault at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-07-28  5:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pault at gcc dot gnu dot org  2007-07-28 05:30 -------
Fixed on trunk and IVS testsuite gives a clean sweep of greens - yipee!

Paul


-- 

pault at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2007-07-28  5:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-24 15:56 [Bug fortran/32880] New: User operator & allocatable TYPE components: wrong deallocate burnus at gcc dot gnu dot org
2007-07-24 16:20 ` [Bug fortran/32880] " burnus at gcc dot gnu dot org
2007-07-24 19:57 ` pault at gcc dot gnu dot org
2007-07-25  5:20 ` pault at gcc dot gnu dot org
2007-07-27 17:35 ` patchapp at dberlin dot org
2007-07-28  5:29 ` pault at gcc dot gnu dot org
2007-07-28  5:30 ` pault at gcc dot gnu dot org

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