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

Correct issues from investigation of VSO-938163 #1191

Merged
merged 1 commit into from
Aug 18, 2020

Conversation

CaseyCarter
Copy link
Member

I've been helping the MSVC compiler team's constexpr specialist investigate VSO-938163 (which we'll call "constexpr hates ranges::iter_swap") and its interactions with our Ranges tests. She discovered there are really two different bugs that we've been calling VSO-938163, and fixed them both. In the process we found some miscategorization and other problems hidden behind VSO-938163.

  • <algorithm>: Applied perma-workaround for VSO-1141368 ("constexpr hates lifetime extension") by avoiding structured binding and the consequent lifetime extension of temporaries implicitly bound to references.

  • tests/std/tests/P0896R4_P1614R2_comparisons: This test triggers a different bug for which I filed VSO-1168721 with a minimal repro:

    struct B {};
    struct D : B {};
    
    constexpr bool test() {
        D some_deriveds[2] = {};
    
        return &some_deriveds[0] < static_cast<B *>(&some_deriveds[1]);
    }
    static_assert(test(), "FAIL");

    I've changed the TRANSITION comment appropriately.

  • tests/std/tests/P0896R4_ranges_alg_partition: In addition to VSO-938163, this triggers VSO-1168723 in which std::array<std::pair<int, int>, N>'s implicit copy assignment operator is incorrectly not considered constexpr despite that std::pair<int, int> can be copy assigned in a constant expression. I've applied a perma-workaround to avoid VSO-1168723.

  • tests/std/tests/P0896R4_ranges_iterator_machinery: Change #ifdef __clang__ guard to #if defined(__clang__) || defined(__EDG__) for consistency.

I've verified that the tests will all pass with the fixed compiler after applying these changes and removing all remaining workarounds for VSO-938163, which we'll be able to do after the fixed compiler ships.

* `<algorithm>`: Applied perma-workaround for VSO-1141368 by avoiding structured binding and the consequent lifetime extension of temporaries implicitly bound to references.
* `tests/std/tests/P0896R4_P1614R2_comparisons`: The compiler team determined that this is a different bug for which I filed VSO-1168721 with a minimal repro. I've changed the TRANSITION comment appropriately.
* `tests/std/tests/P0896R4_ranges_alg_partition`: In addition to VSO-938163, this triggers VSO-1168723 in which `std::array<std::pair<int, int>, N>`'s implicit copy assignment operator is incorrectly not considered `constexpr` despite that `std::pair<int, int>` can be copy assigned in a constant expression. I've applied a perma-workaround to avoid VSO-1168723.
* `tests/std/tests/P0896R4_ranges_iterator_machinery`: Change `#ifdef __clang__` guard to `#if defined(__clang__) || defined(__EDG__)` for consistency.
@CaseyCarter CaseyCarter added the enhancement Something can be improved label Aug 13, 2020
@CaseyCarter CaseyCarter requested a review from a team as a code owner August 13, 2020 22:49
@StephanTLavavej StephanTLavavej merged commit 1306963 into microsoft:master Aug 18, 2020
@StephanTLavavej
Copy link
Member

Thanks for investigating and cleaning up these workarounds! 😺 This helps keep the STL from accumulating unnecessary complexity.

@CaseyCarter CaseyCarter deleted the workarounds branch August 18, 2020 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Something can be improved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants