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

Opt<T> missing destructor calls of inner type T #4

Closed
johannst opened this issue Apr 8, 2024 · 0 comments · Fixed by #5
Closed

Opt<T> missing destructor calls of inner type T #4

johannst opened this issue Apr 8, 2024 · 0 comments · Fixed by #5

Comments

@johannst
Copy link
Contributor

johannst commented Apr 8, 2024

Hi,

I wanted to report, when using Opt<T> there are some cases where the number of destructor calls of the inner type do not match the number of constructor calls.

See the following reproducer (attached tarball for convenience).

// emplace.cc
#include <rpp/base.h>
#include <rpp/opt.h>

#include "printer.h"

int main() {
    rpp::Opt<printer> o1;

    o1.emplace();
    o1.emplace();
}

// output:
// printer::printer()
// printer::printer()
// printer::~printer()
// move_assign.cc
#include <rpp/base.h>
#include <rpp/opt.h>

#include "printer.h"

int main() {
    rpp::Opt<printer> o1;
    rpp::Opt<printer> o2;

    o1.emplace();
    o2 = rpp::move(o1);
}

// output:
// printer::printer()
// printer::printer(printer &&)
// printer::~printer()
// move_construct.cc
#include <rpp/base.h>
#include <rpp/opt.h>

#include "printer.h"

int main() {
    rpp::Opt<printer> o1;
    o1.emplace();

    rpp::Opt<printer> o2(rpp::move(o1));
}

// output:
// printer::printer()
// printer::printer(printer &&)
// printer::~printer()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant