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

Initialization from `failure_type` drops default-constructed values #115

Closed
akrzemi1 opened this issue Jan 26, 2018 · 2 comments
Closed

Initialization from `failure_type` drops default-constructed values #115

akrzemi1 opened this issue Jan 26, 2018 · 2 comments
Assignees
Labels
bug

Comments

@akrzemi1
Copy link
Collaborator

@akrzemi1 akrzemi1 commented Jan 26, 2018

The result of initializing an outcome with a default-constructed error (or exception) has different results if done directly versus through failure_type:

#include "outcome.hpp"
namespace out = OUTCOME_V2_NAMESPACE;

int main()
{  
    {
        out::outcome<int> o = std::error_code{};
        assert (o.has_error());
    }
    {
        out::outcome<int> o = out::failure(std::error_code{});
        assert (!o.has_error());
    }
}
@ned14 ned14 added the bug label Jan 28, 2018
@ned14

This comment has been minimized.

Copy link
Owner

@ned14 ned14 commented Jan 28, 2018

I've figured out the cause: outcome compares the E in failure_type to default constructed editions to determine whether to set EC or EP. That's such an obvious bug. I don't know what I was thinking when I wrote that code. THANK YOU.

@ned14 ned14 self-assigned this Mar 22, 2018
ned14 added a commit that referenced this issue Mar 24, 2018
Inexplicably outcome's error + exception constructor had been removed.
Nobody noticed during the Boost peer review, which is worrying seeing as that
constructor is needed for one of the main advertised features to Boost!
@ned14

This comment has been minimized.

Copy link
Owner

@ned14 ned14 commented Mar 24, 2018

Fixed

@ned14 ned14 closed this Mar 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.