Skip to content

Commit cf6feff

Browse files
mordanteldionne
andauthored
[libc++] Avoids using ENODATA. (#86165)
This macro is deprecated in C++26. Fixes #81360 --------- Co-authored-by: Louis Dionne <[email protected]>
1 parent eea3bd3 commit cf6feff

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

libcxx/docs/ReleaseNotes/19.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,10 @@ TODO
117117

118118
ABI Affecting Changes
119119
---------------------
120-
TODO
120+
121+
- The optional POSIX macro ``ENODATA`` has been deprecated in C++ and POSIX 2017. The
122+
``random_device`` could throw a ``system_error`` with this value. It now
123+
throws ``ENOMSG``.
121124

122125

123126
Build System Changes

libcxx/src/random.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,8 @@ unsigned random_device::operator()() {
7979
char* p = reinterpret_cast<char*>(&r);
8080
while (n > 0) {
8181
ssize_t s = read(__f_, p, n);
82-
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
8382
if (s == 0)
84-
__throw_system_error(ENODATA, "random_device got EOF"); // TODO ENODATA -> ENOMSG
85-
_LIBCPP_SUPPRESS_DEPRECATED_POP
83+
__throw_system_error(ENOMSG, "random_device got EOF");
8684
if (s == -1) {
8785
if (errno != EINTR)
8886
__throw_system_error(errno, "random_device got an unexpected error");

0 commit comments

Comments
 (0)