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 test suite issues discovered by Clang 15 #3135

Merged
merged 1 commit into from
Oct 12, 2022

Conversation

CaseyCarter
Copy link
Member

I validated the STL against Clang 15.0.1, which may be shipping Soon(TM) with Visual Studio.

  • Clang's "initialized but unused variable" warning got smarter, and noticed that do_random_test::gen_data in tests/tr1/include/tspec_random.h initialized int n = 0, incremented n some number of times, and never used the resulting value. I've removed the offending variable.

  • Clang diagnosed the subsumption test in tests/std/P0898R3_concepts as ill-formed due to ambiguity. The test does something like: c++ constexpr bool f(auto&&) { return false; } constexpr bool f(integral auto) { return true; } static_assert(f(42)); intending that f(integral auto) is called with the belief that its contraints subsume those of f(auto&&). This was derived from similar subsumption tests I wrote for concepts in cmcstl2 and range-v3 which GCC's TS-era concepts implementation once accepted, but current GCC and Clang both reject it. I suspect MSVC and Clang 14 were wrong to accept the code and the call should be ambiguous, but I need to dig into the wording for partial ordering of function templates before filing a bug against MSVC. In any case, we can change f(auto&&) to f(auto) without impacting the test - the arguments used in the test all have scalar types - so let's do so.

  • Clang diagnosed hundreds of unqualified calls to move and forward in our tests thanks to a new unqualified-std-cast-call warning. I don't address these in this PR, I've instead opened test: hundreds of failures with Clang 15.0.1 #3134 for us to discuss precisely how we do want to address it.

I validated the STL against Clang 15.0.1, which may be shipping Soon(TM) with Visual Studio.

* Clang's "initialized but unused variable" warning got smarter, and noticed that `do_random_test::gen_data` in `tests/tr1/include/tspec_random.h` initialized `int n = 0`, incremented `n` some number of times, and never used the resulting value. I've removed the offending variable.

* Clang diagnosed the subsumption test in `tests/std/P0898R3_concepts` as ill-formed due to ambiguity. The test does something like:
  ```c++
  constexpr bool f(auto&&) { return false; }
  constexpr bool f(integral auto) { return true; }
  static_assert(f(42));
  ```
  intending that `f(integral auto)` is called with the belief that its contraints subsume those of `f(auto&&)`. This was derived from similar subsumption tests I wrote for concepts in cmcstl2 and range-v3 which GCC's TS-era concepts implementation once accepted, but current GCC and Clang both reject it. I suspect MSVC and Clang 14 were wrong to accept the code and the call _should_ be ambiguous, but I need to dig into the wording for partial ordering of function templates before filing a bug against MSVC. In any case, we can change `f(auto&&)` to `f(auto)` without impacting the test - the arguments used in the test all have scalar types - so let's do so.

* Clang diagnosed hundreds of unqualified calls to `move` and `forward` in our tests thanks to a new `unqualified-std-cast-call` warning. I don't address these in this PR, I've instead opened microsoft#3134 for us to discuss precisely how we do want to address it.
@CaseyCarter CaseyCarter added the test Related to test code label Sep 29, 2022
@CaseyCarter CaseyCarter requested a review from a team as a code owner September 29, 2022 08:06
Copy link
Contributor

@strega-nil-ms strega-nil-ms left a comment

Choose a reason for hiding this comment

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

These changes look completely reasonable to me.

@StephanTLavavej StephanTLavavej self-assigned this Oct 11, 2022
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit 9de55f1 into microsoft:main Oct 12, 2022
@StephanTLavavej
Copy link
Member

Thanks for scouting ahead and fixing these failures! 😻 🛠️ ✨

@CaseyCarter CaseyCarter deleted the clang15 branch October 12, 2022 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Related to test code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants