Skip to content

Commit

Permalink
[libc++] Fix lifetime issues of temporaries.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mordante committed Nov 9, 2021
1 parent a948a0a commit 1e78d5d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -50,9 +47,11 @@ void test() {
!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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -34,9 +31,11 @@ void test() {
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;
Expand Down

0 comments on commit 1e78d5d

Please sign in to comment.