-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
🔧 Fix up a few more effc++ items #858
Conversation
The tests should succeed... Can you make sure you on the latest |
What are the errors? |
Ok, my bad. The failures were with gcc 4.9.3. When run under 5.4.0-6ubuntu1~16.04.5 everything passes. |
Hm... GCC 4.9 should work as well. Could you post the errors? |
And which compiler created the |
Original effc++ warnings were from icc (ICC) 11.0 20081105. I'll dig them up and post them here. Sorry, never used ctest -- how can I get it to print the specific errors? I just get very general message currently:
thanks |
You can use |
src/json.hpp
Outdated
@@ -6101,7 +6101,9 @@ class serializer | |||
@param[in] ichar indentation character to use | |||
*/ | |||
serializer(output_adapter_t<char> s, const char ichar) | |||
: o(std::move(s)), loc(std::localeconv()), | |||
: o(std::move(s)), | |||
number_buffer(), |
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.
What is the warning that led to adding number_buffer()
here? The member is initialized in the definition:
std::array<char, 64> number_buffer{{}};
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.
It was bad icc check -- I think this change is not really necessary.
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.
Thanks for checking back. Could you revert this change please?
src/json.hpp
Outdated
@@ -8011,6 +8013,7 @@ class basic_json | |||
json_value(number_float_t v) noexcept : number_float(v) {} | |||
/// constructor for empty values of a given type | |||
json_value(value_t t) | |||
: object(nullptr) |
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.
If this is required, then maybe we can remove the lines
object = nullptr; // silence warning, see #821
below which have been added when discussing #821.
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.
Related: line 8073 is now unreachable due to the case added at line 8062. That line should be moved into the new case if it's still desirable, or removed altogether along with the surrounding if().
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.
That case was always unreachable and was only added to get the hash 961c151d2e87f2686a955a9be24d316f1362bf21
into binaries using the library.
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.
Interesting. Perhaps a comment is in order then.
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 think this can be removed -- it was bad icc check.
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.
Thanks. Could you remove the mentioned line above please?
@mattismyname Could you comment on #858 (review) and #858 (review)? |
@mattismyname Could you please comment on #858 (review) and #858 (review)? I would like to have this PR merged for the upcoming release. |
Sorry for slowness |
src/json.hpp
Outdated
@@ -6101,7 +6101,9 @@ class serializer | |||
@param[in] ichar indentation character to use | |||
*/ | |||
serializer(output_adapter_t<char> s, const char ichar) | |||
: o(std::move(s)), loc(std::localeconv()), | |||
: o(std::move(s)), | |||
number_buffer(), |
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.
Thanks for checking back. Could you revert this change please?
src/json.hpp
Outdated
@@ -8011,6 +8013,7 @@ class basic_json | |||
json_value(number_float_t v) noexcept : number_float(v) {} | |||
/// constructor for empty values of a given type | |||
json_value(value_t t) | |||
: object(nullptr) |
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.
Thanks. Could you remove the mentioned line above please?
3fee464
to
bbe61d7
Compare
I've pushed the requested fixes to mattismyname/json develop branch. |
bbe61d7
to
72bff90
Compare
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.
Looks good to me.
Thanks a lot! |
Commit f28fc22 introduced const qualifiers on post-(inc-/dec-)rement operators of iterators. These qualifiers prevent the use of basic_json in place of std::ranges::Range, which requires the post-increment operator to be equality-preserving. These changes appear to be the result of compiler suggestions, and no further explanation is discernible from the PR discussion (nlohmann#858). This commit partially reverts f28fc22, removing all added const qualifiers. Fixes nlohmann#3331.
Commit f28fc22 introduced const qualifiers on post-(inc-/dec-)rement operators of iterators. These qualifiers prevent the use of basic_json in place of std::ranges::Range, which requires the post-increment operator to be equality-preserving. These changes appear to be the result of compiler suggestions, and no further explanation is discernible from the PR discussion (nlohmann#858). This commit partially reverts f28fc22, removing all added const qualifiers. Fixes nlohmann#3331.
Commit f28fc22 introduced const qualifiers on post-(inc-/dec-)rement operators of iterators. These qualifiers prevent the use of basic_json in place of std::ranges::range, which requires the post-increment operator to be equality-preserving. These changes appear to be the result of compiler suggestions, and no further explanation is discernible from the PR discussion (nlohmann#858). This commit partially reverts f28fc22, removing all added const qualifiers. Fixes nlohmann#3331.
Commit f28fc22 introduced const qualifiers on post-(inc-/dec-)rement operators of iterators. These qualifiers prevent the use of basic_json in place of std::ranges::range, which requires the post-increment operator to be equality-preserving. These changes appear to be the result of ICC compiler suggestions, and no further explanation is discernible from the PR discussion (nlohmann#858). Further testing revealed, that clang-tidy also suggests adding const to prevent "accidental mutation of a temporary object". As an alternative, this commit partially reverts f28fc22, removing all added const qualifiers from return types and adds lvalue reference qualifiers to the operator member functions instead. Unit tests ensure the operators remain equality-preserving and accidental mutation of temporaries following post-(inc-/dec-)rement is prohibited. Fixes nlohmann#3331.
Commit f28fc22 introduced const qualifiers on post-(inc-/dec-)rement operators of iterators. These qualifiers prevent the use of basic_json in place of std::ranges::range, which requires the post-increment operator to be equality-preserving. These changes appear to be the result of ICC compiler suggestions, and no further explanation is discernible from the PR discussion (nlohmann#858). Further testing revealed, that clang-tidy also suggests adding const to prevent "accidental mutation of a temporary object". As an alternative, this commit partially reverts f28fc22, removing all added const qualifiers from return types and adds lvalue reference qualifiers to the operator member functions instead. Unit tests ensure the operators remain equality-preserving and accidental mutation of temporaries following post-(inc-/dec-)rement is prohibited. Fixes nlohmann#3331.
Commit f28fc22 introduced const qualifiers on post-(inc-/dec-)rement operators of iterators. These qualifiers prevent the use of basic_json in place of std::ranges::range, which requires the post-increment operator to be equality-preserving. These changes appear to be the result of ICC compiler suggestions, and no further explanation is discernible from the PR discussion (#858). Further testing revealed, that clang-tidy also suggests adding const to prevent "accidental mutation of a temporary object". As an alternative, this commit partially reverts f28fc22, removing all added const qualifiers from return types and adds lvalue reference qualifiers to the operator member functions instead. Unit tests ensure the operators remain equality-preserving and accidental mutation of temporaries following post-(inc-/dec-)rement is prohibited. Fixes #3331.
test suite has these two failures, but the same tests fail even before this change:
21/70 Test #62: test-regression_all .................***Failed 12.56 sec
29/70 Test #61: test-regression_default .............***Failed 12.91 sec