Skip to content

Conversation

@AlexGuteniev
Copy link
Contributor

@AlexGuteniev AlexGuteniev commented Apr 1, 2020

Description

Fix #669

Checklist

Be sure you've read README.md and understand the scope of this repo.

If you're unsure about a box, leave it unchecked. A maintainer will help you.

  • Identifiers in product code changes are properly _Ugly as per
    https://eel.is/c++draft/lex.name#3.1 or there are no product code changes.
  • The STL builds successfully and all tests have passed (must be manually
    verified by an STL maintainer before automated testing is enabled on GitHub,
    leave this unchecked for initial submission).
  • These changes introduce no known ABI breaks (adding members, renaming
    members, adding virtual functions, changing whether a type is an aggregate
    or trivially copyable, etc.).
  • These changes were written from scratch using only this repository,
    the C++ Working Draft (including any cited standards), other WG21 papers
    (excluding reference implementations outside of proposed standard wording),
    and LWG issues as reference material. If they were derived from a project
    that's already listed in NOTICE.txt, that's fine, but please mention it.
    If they were derived from any other project (including Boost and libc++,
    which are not yet listed in NOTICE.txt), you must mention it here,
    so we can determine whether the license is compatible and what else needs
    to be done.

@AlexGuteniev AlexGuteniev requested a review from a team as a code owner April 1, 2020 19:56
@cbezault cbezault changed the title Fix #669 <bitset>: Make bitset::all work like bitset::any Apr 1, 2020
Yes, it's better.
@CaseyCarter CaseyCarter added the performance Must go faster label Apr 1, 2020
@AlexGuteniev
Copy link
Contributor Author

The test are failed due to warning:

3: C:\agent\_work\1\a\x64\out\inc\bitset(403): error C2220: the following warning is treated as an error
3: C:\agent\_work\1\a\x64\out\inc\bitset(403): warning C4127: conditional expression is constant
3: C:\agent\_work\1\a\x64\out\inc\bitset(403): note: consider using 'if constexpr' statement instead
3: C:\agent\_work\1\a\x64\out\inc\bitset(402): note: while compiling class template member function 'bool std::bitset<5>::all(void) noexcept const'
3: C:\agent\_work\1\s\tests\tr1\tests\bitset\test.cpp(82): note: see reference to function template instantiation 'bool std::bitset<5>::all(void) noexcept const' being compiled
3: C:\agent\_work\1\s\tests\tr1\tests\bitset\test.cpp(13): note: see reference to class template instantiation 'std::bitset<5>' being compiled
3: C:\agent\_work\1\a\x64\out\inc\bitset(411): warning C4127: conditional expression is constant
3: C:\agent\_work\1\a\x64\out\inc\bitset(411): note: consider using 'if constexpr' statement instead

I can suppress them locally, but maybe need to embed suppression to _CONSTEXPR_IF?

Copy link
Member

@StephanTLavavej StephanTLavavej 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, just minor nitpicks. Thanks!

@StephanTLavavej
Copy link
Member

I can suppress them locally, but maybe need to embed suppression to _CONSTEXPR_IF?

That's an interesting idea - I hadn't considered embedding a _Pragma into that macro, but if it works, it would resolve most of our local C4127 suppressions!

@CaseyCarter
Copy link
Contributor

I can suppress them locally, but maybe need to embed suppression to _CONSTEXPR_IF?

That's an interesting idea - I hadn't considered embedding a _Pragma into that macro, but if it works, it would resolve most of our local C4127 suppressions!

We've been using the

constexpr bool _Meow = /* some constant expression */;
if _CONSTEXPR_IF (_Meow) {

trick to avoid C4127 in newer code rather than suppressing it. The only suppressions are in "old" things that probably aren't using if constexpr or if _CONSTEXPR_IF.

@AlexGuteniev
Copy link
Contributor Author

I assume that _Pragma("warning(suppress : N)") would work.

I recall __pragma(warning(suppress : N)) worked in VS2005 or VS2008.
It had some problems on duration of its effect when statement ends not in next line - in some cases suppression lasted unexpectedly long (by a line or two off). I'm afraid I can't prove this claim with repro, it has been ten years, so I rather hope it is fixed.

Anyway, I'll follow what @CaseyCarter suggests.

Copy link
Member

@StephanTLavavej StephanTLavavej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

@CaseyCarter CaseyCarter self-assigned this Apr 3, 2020
@CaseyCarter CaseyCarter merged commit 260cfaf into microsoft:master Apr 3, 2020
@CaseyCarter
Copy link
Contributor

Thanks for the improvement!

@AlexGuteniev AlexGuteniev deleted the popcnt_all branch April 3, 2020 05:16
fengjixuchui added a commit to fengjixuchui/STL that referenced this pull request Apr 3, 2020
<bitset>: Make bitset::all work like bitset::any (microsoft#671)
@CaseyCarter CaseyCarter removed their assignment Jun 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Must go faster

Projects

None yet

Development

Successfully merging this pull request may close these issues.

<bitset>: bitset::all uses bitset::count when it should work like bitset::any

5 participants