Skip to content

prevent auto-converting const char * to bool in ParmParse::add#4969

Merged
WeiqunZhang merged 4 commits intoAMReX-Codes:developmentfrom
charlesgwaldman:parmparse
Feb 24, 2026
Merged

prevent auto-converting const char * to bool in ParmParse::add#4969
WeiqunZhang merged 4 commits intoAMReX-Codes:developmentfrom
charlesgwaldman:parmparse

Conversation

@charlesgwaldman
Copy link
Copy Markdown
Contributor

Summary

ParmParse::add("key", "value") will result in adding a boolean value (1) due to C++ converting pointer to bool. This is almost certainly not intended. Users must write
add("key", std::string("value") which is cumbersome and easy to forget. Adding explicit const char * -> std::string overload removes this pitfall

Additional background

Checklist

The proposed changes:

  • fix a bug or incorrect behavior in AMReX
  • add new capabilities to AMReX
  • changes answers in the test suite to more than roundoff level
  • are likely to significantly affect the results of downstream AMReX users
  • include documentation in the code and/or rst files, if appropriate

@charlesgwaldman
Copy link
Copy Markdown
Contributor Author

Thanks @WeiqunZhang - that make sense. Clearly I should have used string_view in the first place. I appreciate you taking the time to review this.

@WeiqunZhang WeiqunZhang merged commit 27198db into AMReX-Codes:development Feb 24, 2026
74 checks passed
@charlesgwaldman charlesgwaldman deleted the parmparse branch February 25, 2026 13:43
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.

2 participants