[libcxx-commits] [PATCH] D158749: [libc++] Implement LWG3464(istream::gcount() can overflow)
Yurong via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Aug 24 09:22:25 PDT 2023
yronglin created this revision.
Herald added a project: All.
yronglin requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
Signed-off-by: yrong <yronglin777 at gmail.com>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D158749
Files:
libcxx/docs/Status/Cxx23Issues.csv
libcxx/include/istream
Index: libcxx/include/istream
===================================================================
--- libcxx/include/istream
+++ libcxx/include/istream
@@ -212,6 +212,12 @@
basic_ios<char_type, traits_type>::swap(__rhs);
}
+ inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
+ void __inc_gcount() {
+ if (__gc_ < numeric_limits<streamsize>::max())
+ ++__gc_;
+ }
+
basic_istream (const basic_istream& __rhs) = delete;
basic_istream& operator=(const basic_istream& __rhs) = delete;
public:
@@ -714,7 +720,7 @@
__sb->sputc(traits_type::to_char_type(__i)),
traits_type::eof()))
break;
- ++__gc_;
+ __inc_gcount();
this->rdbuf()->sbumpc();
}
if (__gc_ == 0)
@@ -806,7 +812,7 @@
if (traits_type::eq(__ch, __dlm))
break;
*__s++ = __ch;
- ++__gc_;
+ __inc_gcount();
this->rdbuf()->sbumpc();
}
if (__gc_ == 0)
@@ -867,7 +873,7 @@
break;
if (traits_type::eq_int_type(__sb.sputc(__ch), traits_type::eof()))
break;
- ++__gc_;
+ __inc_gcount();
this->rdbuf()->sbumpc();
}
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
@@ -910,7 +916,7 @@
if (traits_type::eq(__ch, __dlm))
{
this->rdbuf()->sbumpc();
- ++__gc_;
+ __inc_gcount();
break;
}
if (__gc_ >= __n-1)
@@ -920,7 +926,7 @@
}
*__s++ = __ch;
this->rdbuf()->sbumpc();
- ++__gc_;
+ __inc_gcount();
}
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
}
@@ -970,7 +976,7 @@
__state |= ios_base::eofbit;
break;
}
- ++__gc_;
+ __inc_gcount();
if (traits_type::eq_int_type(__i, __dlm))
break;
}
@@ -985,7 +991,7 @@
__state |= ios_base::eofbit;
break;
}
- ++__gc_;
+ __inc_gcount();
if (traits_type::eq_int_type(__i, __dlm))
break;
}
Index: libcxx/docs/Status/Cxx23Issues.csv
===================================================================
--- libcxx/docs/Status/Cxx23Issues.csv
+++ libcxx/docs/Status/Cxx23Issues.csv
@@ -10,7 +10,7 @@
"`3432 <https://wg21.link/LWG3432>`__","Missing requirement for ``comparison_category``","November 2020","|Complete|","16.0","|spaceship|"
"`3447 <https://wg21.link/LWG3447>`__","Deduction guides for ``take_view`` and ``drop_view`` have different constraints","November 2020","|Complete|","14.0","|ranges|"
"`3450 <https://wg21.link/LWG3450>`__","The const overloads of ``take_while_view::begin/end`` are underconstrained","November 2020","|Complete|","16.0","|ranges|"
-"`3464 <https://wg21.link/LWG3464>`__","``istream::gcount()`` can overflow","November 2020","",""
+"`3464 <https://wg21.link/LWG3464>`__","``istream::gcount()`` can overflow","November 2020","|Complete|","18.0"
"`2731 <https://wg21.link/LWG2731>`__","Existence of ``lock_guard<MutexTypes...>::mutex_type`` typedef unclear","November 2020","|Complete|","5.0"
"`2743 <https://wg21.link/LWG2743>`__","P0083R3 ``node_handle`` private members missing ""exposition only"" comment","November 2020","|Nothing To Do|",""
"`2820 <https://wg21.link/LWG2820>`__","Clarify ``<cstdint>`` macros","November 2020","|Nothing To Do|",""
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158749.553162.patch
Type: text/x-patch
Size: 3933 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230824/524bc183/attachment-0001.bin>
More information about the libcxx-commits
mailing list