Skip to content

BUG: Erase empty arguments in sccan before parsing - #2060

Open
hjmjohnson wants to merge 1 commit into
ANTsX:mainfrom
hjmjohnson:bug-sccan-erase-empty-args
Open

hjmjohnson wants to merge 1 commit into
ANTsX:mainfrom
hjmjohnson:bug-sccan-erase-empty-args

Conversation

@hjmjohnson

Copy link
Copy Markdown
Collaborator

sccan meant to drop empty arguments, but it called std::remove without erase, so the vector kept its size and the parser still received the empty strings. sccan "" -h aborted with Unable to convert '' to type 'j' instead of printing the help. This uses the erase-remove idiom and adds a regression test.

Testing

Inner build on macOS (AppleClang, ITK 6), main b463b40 plus this commit:

Command main This PR
sccan -h exit 0, help exit 0, same help
sccan "" -h abort (134), parse error exit 0, same help
sccan -h "" abort (134), parse error exit 0, same help
sccan --svd "" abort, FileName must be specified unchanged (--svd has no value)
  • New test sccan_EMPTY_ARGUMENT (sccan "" -h "", inside RUN_SHORT_TESTS): fails on main, passes with the fix. ctest -R sccan: 3/3 pass.
  • Compiler warnings for sccan.cxx: the same 10 before and after.
  • git clang-format origin/main: no changes.

@hjmjohnson
hjmjohnson marked this pull request as ready for review October 27, 2026 21:41
@hjmjohnson
hjmjohnson requested a review from cookpa October 30, 2026 18:14
@hjmjohnson
hjmjohnson force-pushed the bug-sccan-erase-empty-args branch 2 times, most recently from 8dd587f to 9b6c623 Compare October 30, 2026 18:21
sccan called std::remove on its arguments without erase. std::remove
only moves the kept elements forward; the vector keeps its size, so
argc still counted the empty strings and the parser received them.
`sccan "" -h` aborted with "Unable to convert '' to type 'j'" instead
of printing the help.

Use the erase-remove idiom, and add sccan_EMPTY_ARGUMENT, which runs
`sccan "" -h ""` and fails without the fix.

Assisted-by: Claude Code - found during PR ANTsX#2056 review
@hjmjohnson
hjmjohnson force-pushed the bug-sccan-erase-empty-args branch from 9b6c623 to b9be402 Compare October 30, 2026 19:04
@hjmjohnson
hjmjohnson requested a review from ntustison October 31, 2026 21:52

This branch has not been deployed

No deployments
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 this pull request may close these issues.

1 participant