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 empty control statement warnings #49

Merged
merged 1 commit into from
Oct 19, 2020

Conversation

SigmundVik
Copy link
Contributor

@SigmundVik SigmundVik commented Feb 7, 2020

This change replaces code like this:

      if(safemode_or_autounlink)
         BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));

with:

      BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || node_algorithms::unique(to_insert));

The reason for this change is that the first form generates a warning for Visual C++ 14.1 in builds without asserts:

warning C4390: ';': empty controlled statement found; is this the intent?

Before this change the code was using a mix of the two forms when invoking the BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT() and BOOST_INTRUSIVE_INVARIANT_ASSERT() macros. Now it consistently uses the second form.

This change replaces code like this:
      if(safemode_or_autounlink)
         BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));

with:
      BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || node_algorithms::unique(to_insert));

The reason for this change is that the first form generates
a warning for Visual C++ 14.1 in builds without asserts:
warning C4390: ';': empty controlled statement found; is this the intent?

Before this change the code was using a mix of the two forms
when invoking the BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT()
and BOOST_INTRUSIVE_INVARIANT_ASSERT() macros.  Now it
consistently uses the second form.
@SigmundVik
Copy link
Contributor Author

Please pay special attention to the treap_node_extra_checker call operator change. If the node_traits::get_left() and node_traits::get_right() functions are allowed to have side effects, then we need to use curly braces to fix this case instead of moving the function calls inside the BOOST_INTRUSIVE_INVARIANT_ASSERT() macro invocation.

@igaztanaga igaztanaga merged commit 8879091 into boostorg:develop Oct 19, 2020
@igaztanaga
Copy link
Member

Many thanks for the patch, it looks good, as get_rigth/get_left() is not suppossd to have side-effects

igaztanaga added a commit that referenced this pull request Oct 19, 2020
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.

None yet

2 participants