Index: testsuite/g++.dg/tm/pr47746.C
===================================================================
--- testsuite/g++.dg/tm/pr47746.C	(revision 0)
+++ testsuite/g++.dg/tm/pr47746.C	(revision 0)
@@ -0,0 +1,27 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm" }
+
+class InputStream
+{
+        public:
+        virtual unsigned int readUint32 () = 0;
+};
+
+class Building
+{
+        public:
+        __attribute__((transaction_safe)) Building (InputStream *stream);
+        __attribute__((transaction_safe)) void freeGradients ();
+        void load (InputStream *stream);
+};
+
+Building::Building (InputStream *stream)
+{
+        load(stream);
+}
+
+void Building::load (InputStream *stream)
+{
+        int j = (int)stream->readUint32 ();
+        freeGradients ();
+}
Index: trans-mem.c
===================================================================
--- trans-mem.c	(revision 170360)
+++ trans-mem.c	(working copy)
@@ -4274,6 +4274,27 @@ ipa_tm_insert_gettmclone_call (struct cg
   gimple_call_set_noinline_p (stmt);
 
   gimple_call_set_fn (stmt, callfn);
+
+  /* Discard OBJ_TYPE_REF above, may produce incompatible LHS and RHS
+     for a call statement.  Fix it.  */
+  {
+    tree lhs = gimple_call_lhs (stmt);
+    tree rettype =  TREE_TYPE (TREE_TYPE (TREE_TYPE (callfn)));
+    if (lhs
+	&& !useless_type_conversion_p (TREE_TYPE (lhs), rettype))
+    {
+      tree temp;
+
+      temp = make_rename_temp (rettype, 0);
+      gimple_call_set_lhs (stmt, temp);
+
+      g2 = gimple_build_assign (lhs,
+				fold_build1 (VIEW_CONVERT_EXPR,
+					     TREE_TYPE (lhs), temp));
+      gsi_insert_after (gsi, g2, GSI_SAME_STMT);
+    }
+  }
+
   update_stmt (stmt);
 
   return true;
