Skip to content
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

Merged
merged 1 commit into from
Dec 28, 2017
Merged

Conversation

mattismyname
Copy link
Contributor

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

@nlohmann
Copy link
Owner

nlohmann commented Dec 5, 2017

The tests should succeed... Can you make sure you on the latest develop version?

@theodelrieu
Copy link
Contributor

What are the errors?

@mattismyname
Copy link
Contributor Author

Ok, my bad. The failures were with gcc 4.9.3. When run under 5.4.0-6ubuntu1~16.04.5 everything passes.

@nlohmann
Copy link
Owner

nlohmann commented Dec 5, 2017

Hm... GCC 4.9 should work as well. Could you post the errors?

@nlohmann
Copy link
Owner

nlohmann commented Dec 5, 2017

And which compiler created the -Weffc++ warnings?

@mattismyname
Copy link
Contributor Author

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:

$ ctest -R test-regression_default
Test project /nfs/orto/home/mkgumbel/clt_dev02/json/build
    Start 61: test-regression_default
1/1 Test #61: test-regression_default ..........***Failed    6.87 sec

0% tests passed, 1 tests failed out of 1

Label Time Summary:
default    =   6.87 sec (1 test)

Total Test time (real) =   6.94 sec

The following tests FAILED:
         61 - test-regression_default (Failed)
Errors while running CTest

thanks

@nlohmann
Copy link
Owner

nlohmann commented Dec 5, 2017

You can use --output-on-failure.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 3fee464 on mattismyname:develop into 0e3a0b7 on nlohmann:develop.

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(),
Copy link
Owner

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{{}};

Copy link
Contributor Author

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.

Copy link
Owner

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)
Copy link
Owner

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.

Copy link
Contributor

@gregmarr gregmarr Dec 6, 2017

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().

Copy link
Owner

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.

Copy link
Contributor

@gregmarr gregmarr Dec 6, 2017

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.

Copy link
Contributor Author

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.

Copy link
Owner

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?

@nlohmann
Copy link
Owner

nlohmann commented Dec 8, 2017

@mattismyname Could you comment on #858 (review) and #858 (review)?

@nlohmann
Copy link
Owner

@mattismyname Could you please comment on #858 (review) and #858 (review)? I would like to have this PR merged for the upcoming release.

@mattismyname
Copy link
Contributor Author

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(),
Copy link
Owner

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)
Copy link
Owner

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
Copy link
Contributor Author

I've pushed the requested fixes to mattismyname/json develop branch.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 72bff90 on mattismyname:develop into 3113a52 on nlohmann:develop.

Copy link
Owner

@nlohmann nlohmann left a 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.

@nlohmann nlohmann self-assigned this Dec 28, 2017
@nlohmann nlohmann added this to the Release 3.0.1 milestone Dec 28, 2017
@nlohmann nlohmann merged commit f28fc22 into nlohmann:develop Dec 28, 2017
@nlohmann
Copy link
Owner

Thanks a lot!

falbrechtskirchinger added a commit to falbrechtskirchinger/json that referenced this pull request Feb 15, 2022
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.
falbrechtskirchinger added a commit to falbrechtskirchinger/json that referenced this pull request Feb 15, 2022
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.
falbrechtskirchinger added a commit to falbrechtskirchinger/json that referenced this pull request Feb 15, 2022
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.
falbrechtskirchinger added a commit to falbrechtskirchinger/json that referenced this pull request Feb 15, 2022
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.
falbrechtskirchinger added a commit to falbrechtskirchinger/json that referenced this pull request Feb 17, 2022
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.
nlohmann pushed a commit that referenced this pull request Mar 8, 2022
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants