[all-commits] [llvm/llvm-project] 1c1edd: [libc++] Fixes thread::id's operator<<.
Mark de Wever via All-commits
all-commits at lists.llvm.org
Sat Jul 15 02:52:36 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 1c1edd1b5d00daae2efdfbc5754a9fae77597dd4
https://github.com/llvm/llvm-project/commit/1c1edd1b5d00daae2efdfbc5754a9fae77597dd4
Author: Mark de Wever <koraq at xs4all.nl>
Date: 2023-07-15 (Sat, 15 Jul 2023)
Changed paths:
M libcxx/include/__thread/thread.h
M libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp
Log Message:
-----------
[libc++] Fixes thread::id's operator<<.
The output of
template<class charT, class traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& out, thread::id id);
is affected by the state of out. The wording states
[thread.thread.id]/2
The text representation for the character type charT of an object of
type thread::id is an unspecified sequence of charT such that, for two
objects of type thread::id x and y, if x == y is true, the thread::id
objects have the same text representation, and if x != y is true, the
thread::id objects have distinct text representations.
[thread.thread.id]/9
template<class charT, class traits>
basic_ostream<charT, traits>&
operator<< (basic_ostream<charT, traits>& out, thread::id id);
Effects: Inserts the text representation for charT of id into out.
This wording changed in C++23 due to adding a formatter specialization for
thread::id. However the requirement was the same in older versions of C++.
This issue is that thread::id is an integral or pointer and affected by the
formatting manipulators for them. Thus the text representation can differ if
x == y which violates the requirements.
The fix has to hard-code some formatting style for the text
representation. It uses the Standard specified default values
Table 124: basic_ios::init() effectsâ[tab:basic.ios.cons] flags()
flags() skipws | dec
Fixes PR: https://llvm.org/PR62073
Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D153336
More information about the All-commits
mailing list