Repository navigation
Fix #15298: Internal error with invalid escape sequence. #9104
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
| #include "vf_common.h" | ||
|
|
||
| #include "astutils.h" | ||
| #include "errortypes.h" | ||
| #include "library.h" | ||
| #include "mathlib.h" | ||
| #include "path.h" | ||
|
|
@@ -137,6 +138,8 @@ namespace ValueFlow | |
| setTokenValue(tok, std::move(value), settings); | ||
| } catch (const std::exception & /*e*/) { | ||
| // Bad character literal | ||
| } catch (const InternalError & /*e*/) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AI review With this catch, valueflow skips the bad literal. Checks that convert void f(char c) {
if (c == '\s' && c == '\q') {}
}
|
||
| // Bad character literal | ||
| } | ||
| } else if (tok->isNumber() && MathLib::isFloat(tok->str())) { | ||
| // A long double literal out of the range of double (1e400L) has no | ||
|
|
@@ -323,6 +326,9 @@ namespace ValueFlow | |
| catch (const std::exception& /*e*/) { | ||
| // Bad integer literal | ||
| } | ||
| catch (const InternalError& /*e*/) { | ||
| // Bad character literal | ||
| } | ||
| } | ||
| sz = 0; | ||
| break; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AI review
This catches the throw in valueflow. But
TemplateSimplifier::simplifyCalculations(templatesimplifier.cpp:2766-2769) also callsMathLib::toBigNumber(tok)on a%char%token with no catch. Inside template arguments the invalid escape still gives an internal error:The same happens with
U<('\s' > 3)> u2;fortemplate<int N> struct U {};. To fix it, catch the error there too and leave the token unchanged, and add a test for it.