boostorg / boostorg/pfr

char reading in io_fields.hpp does not ignore newline and spaces

Open
#159 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
1.5k
Forks
176
Avg merge
5d 21h
Merged PRs (30d)
1

Description

Since the opening curly braces '{' is read as a char, newlines and spaces set the state "failbit".

This can be an issue for serializing containers in a struct, which usually require the size to be read and then the sequence.

It would be silly to pollute users serialization functions for containers with the curly braces.

Therefore, I changed my local copy of io_fields to read:
char parenthis = {}; // That is in the original.
do
{
in >> parenthis;
}
while(parenthis=='\n'||parenthis==' ');
if (parenthis != '{') in.setstate(std::basic_istream::failbit);

Will think about a better solution later.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating io_fields.hpp and tracing the character read used for the opening '{' during container serialization. Reproduce the case with newlines or spaces before the brace, then verify that valid whitespace-separated input no longer sets failbit while invalid input still does.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.