https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64397

--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
The difference in the dumps for

program main
  use num
  type(my_integer) :: a, c
  a=my_integer([1])
  c = a                       ! -
end

and

program main
  use num
  type(my_integer) :: a, c
  a=my_integer([1])
  c = (a)                     ! +
end

is

--- pr64397_red.f90.003t.original    2014-12-23 22:44:37.000000000 +0100
+++ pr64397_red_1.f90.003t.original    2014-12-23 22:45:12.000000000 +0100
@@ -276,7 +276,7 @@ ass (struct __class_num_My_integer_t & r
             {
               if (a->_data->x.data != 0B)
                 {
-                  _gfortran_runtime_error_at (&"At line 17 of file
pr64397_red.f90"[1]{lb: 1 sz: 1}, &"Attempting to allocate already allocated
variable \'%s\'"[1]{lb: 1 sz: 1}, &"a"[1]{lb: 1 sz: 1});
+                  _gfortran_runtime_error_at (&"At line 17 of file
pr64397_red_1.f90"[1]{lb: 1 sz: 1}, &"Attempting to allocate already allocated
variable \'%s\'"[1]{lb: 1 sz: 1}, &"a"[1]{lb: 1 sz: 1});
                 }
               else
                 {
@@ -445,14 +445,40 @@ MAIN__ ()
     class.11._data->x.data = 0B;
   }
   {
+    void * restrict D.3563;
+    integer(kind=8) D.3562;
+    integer(kind=8) D.3561;
+    integer(kind=8) D.3560;
+    struct __class_num_My_integer_t D.3559;
+    struct my_integer D.3558;
     struct __class_num_My_integer_t class.16;
     struct __class_num_My_integer_t class.15;

     class.15._vptr = (struct __vtype_num_My_integer * {ref-all})
&__vtab_num_My_integer;
     class.15._data = (struct my_integer *) &c;
     class.16._vptr = (struct __vtype_num_My_integer * {ref-all})
&__vtab_num_My_integer;
-    class.16._data = (struct my_integer *) &a;
+    D.3558 = a;
+    class.16._data = (struct my_integer *) &D.3558;
+    D.3559 = class.16;
     ass (&class.15, &class.16);
+    if ((void *) D.3559.x.data != 0B)
+      {
+        D.3560 = (D.3559.x.dim[0].ubound - D.3559.x.dim[0].lbound) + 1;
+        D.3561 = NON_LVALUE_EXPR <D.3560>;
+      }
+    if (class.16._data->x.data != 0B)
+      {
+        __builtin_free ((void *) class.16._data->x.data);
+      }
+    class.16._data->x.data = 0B;
   }
 }

Reply via email to