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

Pass ExcNoMatch the description directly #9783

Merged
merged 1 commit into from Apr 1, 2020

Conversation

peterrum
Copy link
Member

@nfehn has reported that the following program segfaults:

#include <deal.II/base/parameter_handler.h>


using namespace dealii;

int
main(int argc, char ** argv)
{
  try
  {
     unsigned int i = numbers::invalid_unsigned_int;

     ParameterHandler params;
     params.add_parameter("dummy", i);

  }
  catch(std::exception & exc)
  {
    std::cout << exc.what() << std::endl;
  }

}

The function call add_parameter() fails because the variable does not match the pattern (this is wanted in this example). An exception (ExcNoMatch) is thrown, whose content (PatternBase) does not live in the catch-clause:

DeclException2(ExcNoMatch,
std::string,
const Patterns::PatternBase *,
<< "The string " << arg1 << " does not match the pattern \""
<< arg2->description() << "\"");

I think this is an unwanted behavior, isn't it? With replacing the pattern directly by the string, this problem could be fixed.

@luca-heltai What do you think?

@luca-heltai
Copy link
Member

Yes, I agree. Passing const Patterns::PatternBase * should be avoided. Passing directly the description of the pattern would be the correct option.

@luca-heltai luca-heltai added this to the Release 9.2 milestone Apr 1, 2020
@luca-heltai
Copy link
Member

/rebuild

@luca-heltai luca-heltai self-assigned this Apr 1, 2020
@masterleinad
Copy link
Member

/rebuild

@masterleinad masterleinad merged commit 261f131 into dealii:master Apr 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants