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

Implement LWG-3746 optional's spaceship with U with a type derived from optional causes infinite constraint meta-recursion #3265

Merged
merged 5 commits into from
Dec 6, 2022

Conversation

frederick-vs-ja
Copy link
Contributor

Fixes #3225.

I found that MSVC's behavior is strange during testing (Godbolt link), so currently I haven't add the original example yet.

#include <optional>

struct derived_optional : std::optional<int> {
    friend bool operator==(const derived_optional&, const derived_optional&) = default;
    friend auto operator<=>(const derived_optional&, const derived_optional&) = default;
};

int main()
{
    derived_optional a;
    std::optional<derived_optional> b;
#ifdef LESS // If b < a is not skipped, then MSVC accepts b <=> a.
    (void) (b < a);
#endif
    (void) (b <=> a);
}

@frederick-vs-ja frederick-vs-ja requested a review from a team as a code owner December 5, 2022 06:46
@StephanTLavavej StephanTLavavej added the LWG Library Working Group issue label Dec 5, 2022
Comment on lines +318 to +319
constexpr derived_optional<decltype(SmallVal)> derived1{std::optional(SmallVal)};
constexpr derived_optional<decltype(SmallVal)> derived2{std::optional(LargeVal)};
Copy link
Member

Choose a reason for hiding this comment

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

No change requested: I observe that these temporaries could be constructed with braces, following our preferred modern convention. Although this test uses braces to construct temporaries elsewhere, I can't quite bring myself to reset testing for such a small issue in test code (which certainly doesn't affect correctness or test coverage).

@StephanTLavavej StephanTLavavej self-assigned this Dec 5, 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 7164d1c into microsoft:main Dec 6, 2022
@StephanTLavavej
Copy link
Member

🛸 ♾️ 🔁

@frederick-vs-ja frederick-vs-ja deleted the lwg-3746 branch December 7, 2022 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LWG Library Working Group issue
Projects
None yet
3 participants
  翻译: