You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
std::fstream still good after closing and updating content #37400
I have a simple program that should show the problem. - with libc++ the stream is still good after closing and further operation. Since also the file content was not updated - at least the stream operation fails on the closed stream and should set either failbit or badbit to reflect the situation.
The standard says nothing about doing things to an fstream after calling close - so libc++'s behavior here is not "non-standard".
However, it is definitely surprising.
I have a patch that makes libc++ act like libstdc++, but I'm still looking into this.
Activity
llvmbot commentedon Jul 4, 2018
assigned to @mclow
mclow commentedon Jul 31, 2018
This is https://stackoverflow.com/questions/51137052/libc-why-is-the-stream-still-good-after-closing (which I think you wrote, too)
The answer I gave there is still correct.
The standard says nothing about doing things to an fstream after calling close - so libc++'s behavior here is not "non-standard".
However, it is definitely surprising.
I have a patch that makes libc++ act like libstdc++, but I'm still looking into this.
Index: include/fstream
--- include/fstream (revision 338379)
+++ include/fstream (working copy)
@@ -702,6 +702,7 @@
_file = 0;
else
__rt = 0;
}
return __rt;
}
mclow commentedon Jan 8, 2019
Committed r350603 to resolve this.