include/rtl/string.hxx  |   15 ++++++++++++++-
 include/rtl/ustring.hxx |   15 ++++++++++++++-
 2 files changed, 28 insertions(+), 2 deletions(-)

New commits:
commit 5f2206e3ccf1cf64d2b11b0e5d419973269920a8
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Fri Oct 13 18:06:53 2023 +0200
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Fri Oct 13 22:41:10 2023 +0200

    O{U]String copy ctor should be constexpr
    
    ...similar to the dtors, which will be useful for some upcoming 
replacements of
    O[U]StringLiteral and O[U]StringConstExpr
    
    Change-Id: Iad905d8466ee76eba1891fbc340073c482d568d5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157944
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/include/rtl/string.hxx b/include/rtl/string.hxx
index 3482bb833ebd..6cc26e7befe3 100644
--- a/include/rtl/string.hxx
+++ b/include/rtl/string.hxx
@@ -247,10 +247,23 @@ public:
 
       @param    str         an OString.
     */
+#if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && 
defined _MANAGED)
+    constexpr
+#endif
     OString( const OString & str )
     {
         pData = str.pData;
-        rtl_string_acquire( pData );
+#if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && 
defined _MANAGED)
+        if (std::is_constant_evaluated()) {
+            //TODO: We would want to
+            //
+            //   assert(SAL_STRING_IS_STATIC(pData));
+            //
+            // here, but that wouldn't work because read of member `str` of 
OUStringLiteral's
+            // anonymous union with active member `more` is not allowed in a 
constant expression.
+        } else
+#endif
+            rtl_string_acquire( pData );
     }
 
 #if defined LIBO_INTERNAL_ONLY
diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx
index fc88942c8277..8e8bd8e9580e 100644
--- a/include/rtl/ustring.hxx
+++ b/include/rtl/ustring.hxx
@@ -224,10 +224,23 @@ public:
 
       @param    str         an OUString.
     */
+#if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && 
defined _MANAGED)
+    constexpr
+#endif
     OUString( const OUString & str )
     {
         pData = str.pData;
-        rtl_uString_acquire( pData );
+#if defined LIBO_INTERNAL_ONLY && !(defined _MSC_VER && _MSC_VER <= 1929 && 
defined _MANAGED)
+        if (std::is_constant_evaluated()) {
+            //TODO: We would want to
+            //
+            //   assert(SAL_STRING_IS_STATIC(pData));
+            //
+            // here, but that wouldn't work because read of member `str` of 
OUStringLiteral's
+            // anonymous union with active member `more` is not allowed in a 
constant expression.
+        } else
+#endif
+            rtl_uString_acquire( pData );
     }
 
 #if defined LIBO_INTERNAL_ONLY

Reply via email to