Index: testsuite/g++.dg/tm/pr47573.C
===================================================================
--- testsuite/g++.dg/tm/pr47573.C	(revision 0)
+++ testsuite/g++.dg/tm/pr47573.C	(revision 0)
@@ -0,0 +1,25 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm" }
+
+template<typename _Tp> class allocator
+{
+        public:
+        allocator() { }
+};
+extern template class allocator<char>;
+
+template<typename _Alloc = allocator<char> > class basic_string
+{
+        public:
+        _Alloc _M_dataplus;
+
+        __attribute__((transaction_safe))    
+        basic_string() : _M_dataplus(_Alloc())
+        {
+        }
+};
+
+int getStringHeight()
+{
+        basic_string<> tmp;
+}
Index: trans-mem.c
===================================================================
--- trans-mem.c	(revision 169788)
+++ trans-mem.c	(working copy)
@@ -4089,7 +4089,7 @@ ipa_tm_create_version (struct cgraph_nod
   new_node = cgraph_copy_node_for_versioning (old_node, new_decl, NULL);
   get_cg_data (old_node)->clone = new_node;
 
-  if (!DECL_EXTERNAL (old_decl))
+  if (cgraph_function_body_availability (old_node) >= AVAIL_OVERWRITABLE)
     tree_function_versioning (old_decl, new_decl, NULL, false, NULL);
 
   /* ?? We should be able to remove DECL_IS_TM_CLONE.  We have enough
