Commit 834e97d
[libc++] Fixes istream::sync. (#76467)
This fixes two issues.
The return value
----------------
Based on the wording
[istream.unformatted]/37
Effects: Behaves as an unformatted input function (as described above),
except that it does not count the number of characters extracted and
does not affect the value returned by subsequent calls to gcount().
After constructing a sentry object, if rdbuf() is a null pointer,
returns -1.
[istream.unformatted]/1
... It then creates an object of class sentry with the default argument
noskipws (second) argument true. If the sentry object returns true, when
converted to a value of type bool, the function endeavors to obtain the
requested input. ...
It could be argued the current behaviour is correct, however
constructing a istream rdbuf() == nullptr creates a sentry that returns
false; its state is always bad in this case.
As mentioned in the bug report, after this change the 3 major
implementations behave the same.
The setting of the state
------------------------
When pubsync returned -1 it updated the local __state variable and
returned. This early return caused the state up the istream not to be
updated to the new state.
Fixes: llvm/llvm-project#51497
Fixes: llvm/llvm-project#51499
---------
Co-authored-by: Louis Dionne <[email protected]>
NOKEYCHECK=True
GitOrigin-RevId: 54daf6af57fb15d7a51e3f4bb889199fd1453bee1 parent 6d83791 commit 834e97d
File tree
2 files changed
+80
-5
lines changed- include
- test/std/input.output/iostream.format/input.streams/istream.unformatted
2 files changed
+80
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1010 | 1010 | | |
1011 | 1011 | | |
1012 | 1012 | | |
1013 | | - | |
1014 | 1013 | | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
1015 | 1018 | | |
1016 | 1019 | | |
1017 | 1020 | | |
1018 | 1021 | | |
1019 | | - | |
1020 | | - | |
1021 | 1022 | | |
1022 | 1023 | | |
1023 | | - | |
| 1024 | + | |
1024 | 1025 | | |
1025 | 1026 | | |
1026 | 1027 | | |
| |||
Lines changed: 75 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
13 | 19 | | |
14 | 20 | | |
15 | 21 | | |
| |||
48 | 54 | | |
49 | 55 | | |
50 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
51 | 69 | | |
52 | 70 | | |
53 | 71 | | |
| |||
85 | 103 | | |
86 | 104 | | |
87 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
88 | 110 | | |
89 | 111 | | |
90 | 112 | | |
91 | 113 | | |
92 | 114 | | |
93 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
94 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
95 | 130 | | |
96 | 131 | | |
97 | 132 | | |
98 | 133 | | |
99 | 134 | | |
100 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
101 | 145 | | |
102 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
103 | 162 | | |
104 | 163 | | |
105 | 164 | | |
| |||
116 | 175 | | |
117 | 176 | | |
118 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
119 | 193 | | |
120 | 194 | | |
121 | 195 | | |
| |||
131 | 205 | | |
132 | 206 | | |
133 | 207 | | |
134 | | - | |
| 208 | + | |
135 | 209 | | |
136 | 210 | | |
137 | 211 | | |
| |||
0 commit comments