-
Notifications
You must be signed in to change notification settings - Fork 1.6k
LWG-3464 istream::gcount() can overflow #1483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LWG-3464 istream::gcount() can overflow #1483
Conversation
barcharcraz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't mind tests for this, but I won't demand them.
|
Thanks for mentioning testing - while thinking about whether it would be practical to test this, I realized that I was confused by reading LWG-3464, which said:
This might not apply to our implementation. We always use Line 49 in c2ab522
Line 664 in c2ab522
Lines 602 to 604 in c2ab522
There's no practical way to exceed 263 - 1, and thus no practical way to test this. However, we are affected by #388 - I'm not sure if that's relevant here. I would guess not, since this is directly incrementing an integer, but I'm not certain. So, I wonder whether we need to make any changes here at all. That said, I believe that the PR clearly doesn't harm correctness, and I believe that it won't harm performance either (the function can be inlined, and the branch is trivially predictable). |
|
Thanks for implementing this LWG issue and making the Status Chart happier (when it's updated next week)! 😸 |
LWG-3464
istream::gcount()can overflow, so in case, if_Chcountis negative, returnstd::numeric_limits<streamsize>::max()Fixes #1480