This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/59568] complex type operator>> does not set eofbit for input streams.
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 13 Dec 2017 11:20:29 +0000
- Subject: [Bug libstdc++/59568] complex type operator>> does not set eofbit for input streams.
- Auto-submitted: auto-generated
- References: <bug-59568-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59568
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The simplest fix is just:
--- a/libstdc++-v3/include/std/complex
+++ b/libstdc++-v3/include/std/complex
@@ -495,6 +495,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_Tp __re_x, __im_x;
_CharT __ch;
__is >> __ch;
+ if (!__is)
+ return __is;
if (__ch == '(')
{
__is >> __re_x >> __ch;
i.e. don't use putback if we didn't extract a character, so don't clear the
eofbit unless there's actually something to putback.
But the current implementation has other problems, like not doing a putback for
the character extracted when a ',' or ')' is not found.
This is closely related to https://wg21.link/lwg2714