[libcxx-commits] [PATCH] D113137: [libc++] Fix lifetime issues of temporaries.

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Nov 4 11:01:06 PDT 2021


Mordante updated this revision to Diff 384817.
Mordante added a comment.

Addresses review comment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113137/new/

https://reviews.llvm.org/D113137

Files:
  libcxx/test/std/utilities/format/format.formatter/format.context/format.context/ctor.pass.cpp
  libcxx/test/std/utilities/format/format.formatter/format.context/format.context/locale.pass.cpp


Index: libcxx/test/std/utilities/format/format.formatter/format.context/format.context/locale.pass.cpp
===================================================================
--- libcxx/test/std/utilities/format/format.formatter/format.context/format.context/locale.pass.cpp
+++ libcxx/test/std/utilities/format/format.formatter/format.context/format.context/locale.pass.cpp
@@ -10,9 +10,6 @@
 // UNSUPPORTED: libcpp-has-no-localization
 // UNSUPPORTED: libcpp-has-no-incomplete-format
 
-// TODO(mordante): Investigate these localization/format failures since updating the Docker image in CI
-// UNSUPPORTED: stdlib=libc++
-
 // REQUIRES: locale.en_US.UTF-8
 // REQUIRES: locale.fr_FR.UTF-8
 
@@ -34,9 +31,11 @@
   std::locale en_US{LOCALE_en_US_UTF_8};
   std::locale fr_FR{LOCALE_fr_FR_UTF_8};
   std::basic_string<CharT> string = MAKE_STRING(CharT, "string");
-  std::basic_format_args args =
-      std::make_format_args<std::basic_format_context<OutIt, CharT>>(
-          true, CharT('a'), 42, string);
+  // The type of the object is an exposition only type. The temporary is needed
+  // to extend the lifetype of the object since args stores a pointer to the
+  // data in this object.
+  auto format_arg_store = std::make_format_args<std::basic_format_context<OutIt, CharT>>(true, CharT('a'), 42, string);
+  std::basic_format_args args = format_arg_store;
 
   {
     std::basic_string<CharT> output;
Index: libcxx/test/std/utilities/format/format.formatter/format.context/format.context/ctor.pass.cpp
===================================================================
--- libcxx/test/std/utilities/format/format.formatter/format.context/format.context/ctor.pass.cpp
+++ libcxx/test/std/utilities/format/format.formatter/format.context/format.context/ctor.pass.cpp
@@ -10,9 +10,6 @@
 // UNSUPPORTED: libcpp-has-no-localization
 // UNSUPPORTED: libcpp-has-no-incomplete-format
 
-// TODO(mordante): Investigate these localization/format failures since updating the Docker image in CI
-// UNSUPPORTED: stdlib=libc++
-
 // REQUIRES: locale.en_US.UTF-8
 // REQUIRES: locale.fr_FR.UTF-8
 
@@ -50,9 +47,11 @@
       !std::is_move_assignable_v<std::basic_format_context<OutIt, CharT>>);
 
   std::basic_string<CharT> string = MAKE_STRING(CharT, "string");
-  std::basic_format_args args =
-      std::make_format_args<std::basic_format_context<OutIt, CharT>>(
-          true, CharT('a'), 42, string);
+  // The type of the object is an exposition only type. The temporary is needed
+  // to extend the lifetype of the object since args stores a pointer to the
+  // data in this object.
+  auto format_arg_store = std::make_format_args<std::basic_format_context<OutIt, CharT>>(true, CharT('a'), 42, string);
+  std::basic_format_args args = format_arg_store;
 
   {
     std::basic_string<CharT> output;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113137.384817.patch
Type: text/x-patch
Size: 2807 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211104/8c9efc2e/attachment-0001.bin>


More information about the libcxx-commits mailing list