-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Assumption that EOF
is enclosed in parantheses (example: (-1)
); otherwise compilation error
#1288
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
Comments
that's quite bad.
static_casr<char>(EOF) is a nonsense expression.
On Thu, Apr 22, 2021 at 7:13 AM Jannik Vogel ***@***.***> wrote:
Previously discussed at DevSolar/pdclib#20 (comment)
<DevSolar/pdclib#20 (comment)>.
These 2 problems exist in jsoncpp:
1. EOF is used in a way that might break certain C implementations (in
our case, pdclib for C + libcxx for C++, with clang as compiler). The code
assumes that EOF will provide paranetheses for dynamic_cast:
https://github.com/open-source-parsers/jsoncpp/blob/94cda30dbddc1859f111848fdd05dfb85d3287c7/src/lib_json/json_reader.cpp#L108
2. EOF isn't a char, but it's used as if it is. EOF is also not very
strictly defined, so the behavior will be C implementation defined.
Typically you get either a char (cast to int) *or* an EOF (int) as
return value from functions like getchar().
Point 1 is easily fixed, but 2 shows that it might not be necessary to fix
it - the problematic code needs to be rewritten.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1288>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACBWORB2C74DRUBNXAQF7YDTKAAEXANCNFSM43MHR6PQ>
.
--
ǝnɥɐuop ʎllıq
|
Hmm. I guess I guess we want this: std::string s(std::istreambuf_iterator<char>(stream), {}); |
cdunn2001
added a commit
that referenced
this issue
May 5, 2021
Merged
cdunn2001
added a commit
that referenced
this issue
May 5, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Previously discussed at DevSolar/pdclib#20 (comment).
These 2 problems exist in jsoncpp:
EOF
is used in a way that might break certain C implementations (in our case, pdclib for C + libcxx for C++, with clang as compiler). The code assumes thatEOF
will provide paranetheses fordynamic_cast
:jsoncpp/src/lib_json/json_reader.cpp
Line 108 in 94cda30
EOF
isn't achar
, but it's used as if it is.EOF
is also not very strictly defined, so the behavior will be C implementation defined. Typically you get either achar
(cast toint
) or anEOF
(int
) as return value from functions likegetchar()
.Point 1 is easily fixed, but 2 shows that it might not be necessary to fix it - the problematic code needs to be rewritten.
The text was updated successfully, but these errors were encountered: