Skip to content

Conversation

@firewave
Copy link
Collaborator

No description provided.

@firewave
Copy link
Collaborator Author

firewave commented Jan 14, 2026

It was only enabled in Windows build. And did not make much sense since the called function does not throw. This also makes it easier to detect uncaught exceptions in static analysis.

@firewave firewave changed the title refs #10736 - removed conditional (NDEBUG) exception handling refs #10736 - cli/main.cpp - removed conditional (NDEBUG) exception handling Jan 14, 2026
@firewave firewave changed the title refs #10736 - cli/main.cpp - removed conditional (NDEBUG) exception handling refs #10736 - cli/main.cpp: removed conditional (NDEBUG) exception handling Jan 14, 2026
@sonarqubecloud
Copy link

return EXIT_FAILURE;
#endif
// *INDENT-ON*
return exec.check(argc, argv);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the ifdef is questionable. but can there be uncaught exceptions from exec.check now? I fear it is UB if we don't catch it. Having a try catch here seems like a good idea unless we are extremely sure there can't be exceptions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't catch it, it will lead to an abnormal process termination. If we annotate the check() function with noexcept (which I considered) that would have the same result. And if we catch it that would not provide much more value since the message would not be available in a head-less scenario (i.e. CI) and to have a parsable result it needs to be caught beforehand and we have catch handlers in place there.

Also potential cases of exceptions slipping through will be detected by static analysis - like danmar/simplecpp#616 was actually reported by Coverity. And upcoming improvements in the bugprone-exception-escape clang-tidy check will also help with this. More usage of noexcept after llvm/llvm-project#168324 has been landed will make things even better. More such annotation will also help detection on our side and the compiler ifself.

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