Index: libcxx/include/sstream
===================================================================
--- libcxx/include/sstream
+++ libcxx/include/sstream
@@ -334,7 +334,15 @@
 #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
     string_type str() const;
 #else
-    _LIBCPP_HIDE_FROM_ABI string_type str() const & { return str(__str_.get_allocator()); }
+
+#ifdef _WIN32
+    // TODO(LLVM 19): Remove this once we drop support for Clang versions which
+    // have this bug: https://github.com/llvm/llvm-project/issues/40363
+    _LIBCPP_ALWAYS_INLINE
+#else
+    _LIBCPP_HIDE_FROM_ABI
+#endif
+    string_type str() const & { return str(__str_.get_allocator()); }
 
     template <class _SAlloc>
       requires __is_allocator<_SAlloc>::value