diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 057f6a63fdf5dd263c4d0b75888b7e8f52c868db..44b091af2c6900603fafba552ef323405cbc67a0 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -10584,10 +10584,9 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, tree dest,
 					   false, false, NULL_TREE, NULL_TREE);
 	      gfc_add_expr_to_block (&fnblock, tmp);
 	    }
-	  else if ((c->attr.allocatable)
-		    && !c->attr.proc_pointer && !same_type
-		    && (!(cmp_has_alloc_comps && c->as) || c->attr.codimension
-			|| caf_in_coarray (caf_mode)))
+	  else if (c->attr.allocatable && !c->attr.proc_pointer
+		   && (!(cmp_has_alloc_comps && c->as) || c->attr.codimension
+		       || caf_in_coarray (caf_mode)))
 	    {
 	      rank = c->as ? c->as->rank : 0;
 	      if (c->attr.codimension)
diff --git a/gcc/testsuite/gfortran.dg/alloc_comp_deep_copy_4.f03 b/gcc/testsuite/gfortran.dg/alloc_comp_deep_copy_4.f03
new file mode 100644
index 0000000000000000000000000000000000000000..3c445be032f6b4440df433390bfa673d037323a8
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/alloc_comp_deep_copy_4.f03
@@ -0,0 +1,29 @@
+!{ dg-do run }
+!
+! Contributed Vladimir Terzi  <vterzi1996@gmail.com>
+! Check that deep-copy for b=a works.
+
+program pr114672
+    type node
+        integer::val
+        type(node),allocatable::next
+    end type
+
+    type(node)::a,b
+
+    allocate(a%next)
+    a%val=1
+    a%next%val=2
+!    print*,a%val,a%next%val
+    b=a
+    b%val=3
+    b%next%val=4
+    if (loc(b) == loc(a)) stop 1
+    if (loc(b%next) == loc(a%next)) stop 2
+!    print*,a%val,a%next%val
+    deallocate(b%next)
+    if (.NOT. allocated(a%next)) stop 3
+!    print*,a%val,a%next%val
+    deallocate(a%next)
+end
+