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

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Nov 9 10:01:30 PST 2021


This revision was automatically updated to reflect the committed changes.
Mordante marked an inline comment as done.
Closed by commit rG1e78d5d008f9: [libc++] Fix lifetime issues of temporaries. (authored by Mordante).

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.385868.patch
Type: text/x-patch
Size: 2807 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211109/6b6d7e3c/attachment.bin>


More information about the libcxx-commits mailing list