Skip to content

Commit 1e78d5d

Browse files
committed
[libc++] Fix lifetime issues of temporaries.
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. This re-enables two of these tests. Reviewed By: ldionne, #libc Differential Revision: https://reviews.llvm.org/D113137
1 parent a948a0a commit 1e78d5d

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
// UNSUPPORTED: libcpp-has-no-localization
1111
// UNSUPPORTED: libcpp-has-no-incomplete-format
1212

13-
// TODO(mordante): Investigate these localization/format failures since updating the Docker image in CI
14-
// UNSUPPORTED: stdlib=libc++
15-
1613
// REQUIRES: locale.en_US.UTF-8
1714
// REQUIRES: locale.fr_FR.UTF-8
1815

@@ -50,9 +47,11 @@ void test() {
5047
!std::is_move_assignable_v<std::basic_format_context<OutIt, CharT>>);
5148

5249
std::basic_string<CharT> string = MAKE_STRING(CharT, "string");
53-
std::basic_format_args args =
54-
std::make_format_args<std::basic_format_context<OutIt, CharT>>(
55-
true, CharT('a'), 42, string);
50+
// The type of the object is an exposition only type. The temporary is needed
51+
// to extend the lifetype of the object since args stores a pointer to the
52+
// data in this object.
53+
auto format_arg_store = std::make_format_args<std::basic_format_context<OutIt, CharT>>(true, CharT('a'), 42, string);
54+
std::basic_format_args args = format_arg_store;
5655

5756
{
5857
std::basic_string<CharT> output;

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
// UNSUPPORTED: libcpp-has-no-localization
1111
// UNSUPPORTED: libcpp-has-no-incomplete-format
1212

13-
// TODO(mordante): Investigate these localization/format failures since updating the Docker image in CI
14-
// UNSUPPORTED: stdlib=libc++
15-
1613
// REQUIRES: locale.en_US.UTF-8
1714
// REQUIRES: locale.fr_FR.UTF-8
1815

@@ -34,9 +31,11 @@ void test() {
3431
std::locale en_US{LOCALE_en_US_UTF_8};
3532
std::locale fr_FR{LOCALE_fr_FR_UTF_8};
3633
std::basic_string<CharT> string = MAKE_STRING(CharT, "string");
37-
std::basic_format_args args =
38-
std::make_format_args<std::basic_format_context<OutIt, CharT>>(
39-
true, CharT('a'), 42, string);
34+
// The type of the object is an exposition only type. The temporary is needed
35+
// to extend the lifetype of the object since args stores a pointer to the
36+
// data in this object.
37+
auto format_arg_store = std::make_format_args<std::basic_format_context<OutIt, CharT>>(true, CharT('a'), 42, string);
38+
std::basic_format_args args = format_arg_store;
4039

4140
{
4241
std::basic_string<CharT> output;

0 commit comments

Comments
 (0)