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

Segmentation fault when default value is C-style string #249

Closed
pfeatherstone opened this issue Dec 16, 2022 · 1 comment · Fixed by #253
Closed

Segmentation fault when default value is C-style string #249

pfeatherstone opened this issue Dec 16, 2022 · 1 comment · Fixed by #253

Comments

@pfeatherstone
Copy link

argparse::ArgumentParser args("Demo");
args.add_argument("--arg").help("Some string arg").required().default_value("bug alert");

Fix:

argparse::ArgumentParser args("Demo");
args.add_argument("--arg").help("Some string arg").required().default_value(std::string("ok"));

Maybe default_value() should have an overload for const char* which automatically converts to std::string

skrobinson added a commit to skrobinson/argparse that referenced this issue Jan 5, 2023
Closes p-ranav#249

Reported-by: @pfeatherstone
Signed-off-by: Sean Robinson <[email protected]>
@skrobinson
Copy link
Contributor

Thank you for your report. I tried a couple approaches, but I think your idea for a fix is the better option.

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.

2 participants