Opened 6 years ago

Closed 6 years ago

#12488 closed Bugs (fixed)

read_string_while duplicates character

Reported by: George <juergen.sawinski@…> Owned by: John Maddock
Milestone: Boost 1.63.0 Component: multiprecision
Version: Boost 1.62.0 Severity: Problem
Keywords: Cc:

Description

Streaming, e.g. "1W" into a multiprecision number will correctly recognize 1, but the first character after the number will be duplicated (from "1W", "WW" is left in the stream).

The cause is the line

is.rdbuf()->sputbackc(static_cast<char>(c));

in read_string_while. The character c does not have to be put back, because snextc first advances position, then returns the character at new position.

Attachments (1)

test.cc (302 bytes ) - added by George <juergen.sawinski@…> 6 years ago.
Test

Download all attachments as: .zip

Change History (3)

by George <juergen.sawinski@…>, 6 years ago

Attachment: test.cc added

Test

comment:1 by George <juergen.sawinski@…>, 6 years ago

Provided test file. Result:

$ g++ -o test test.cc -lmpfr
$ ./test
1.0X
1,'XX'
$

Bug is present in 1.62.0, too.

comment:2 by John Maddock, 6 years ago

Milestone: To Be DeterminedBoost 1.63.0
Resolution: fixed
Status: newclosed
Version: Boost 1.61.0Boost 1.62.0

Fixed in https://github.com/boostorg/multiprecision/commit/1c2ecb6f6ec024d3b7901a50caeab706eda4225f.

Note that I generally need to do a lot more work on the iostream operators.

Note: See TracTickets for help on using tickets.