[libcxx-commits] [PATCH] D113137: [libc++] Fix lifetime issues of temporaries.
Mark de Wever via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Nov 3 12:54:00 PDT 2021
Mordante created this revision.
Mordante added a reviewer: ldionne.
Mordante requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
The ASAN build failed due to using pointers to a temporary whose
lifetime had expired.
Updating the libc++ Docker image to Ubuntu Focal caused some breakage.
This was temporary disabled in D112737 <https://reviews.llvm.org/D112737>. This re-enables two of these
tests.
Repository:
rG LLVM Github Monorepo
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.384562.patch
Type: text/x-patch
Size: 2805 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211103/5279c490/attachment.bin>
More information about the libcxx-commits
mailing list