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

Removing option with a link causes an error #172

Closed
OlivierHartmann opened this issue Oct 9, 2018 · 1 comment
Closed

Removing option with a link causes an error #172

OlivierHartmann opened this issue Oct 9, 2018 · 1 comment
Labels
Milestone

Comments

@OlivierHartmann
Copy link

Hello,

Thank you for this work.
I have found an issue while removing an option that has a link with another one.
Here is a minimalist example causing the bug:

#include <CLI/CLI.hpp>

int main(int argc, char **argv) {

    CLI::App app{"App to demonstrate a bug."};

    int foo, bar;
    auto foo_option = app.add_option("--foo,-f", foo, "An argument");
    app.add_option("--bar", bar, "Another argument")->excludes(foo_option);

    app.remove_option(foo_option);

    CLI11_PARSE(app, argc, argv);
}

Then when running with the "help" flag, we get the following error:

   terminate called after throwing an instance of 'std::bad_alloc'
     what():  std::bad_alloc
   Abandon (core dumped)

The solution can therefore simply be to delete the links at the same time as deleting the option.

Thank you

Olivier

@henryiii henryiii added the bug label Oct 9, 2018
@henryiii
Copy link
Collaborator

This just needs to be checked as part of remove_option, should be pretty easy to add.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants