-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang][Interp] Zero-init remaining string literal elements #66862
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
Conversation
Ping |
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.
Minor comments on testing but I am curious about the size question.
static_assert(a.c[0] == 'a', ""); | ||
static_assert(a.c[1] == 'b', ""); | ||
static_assert(a.c[2] == 'c', ""); | ||
static_assert(a.c[3] == '\0', ""); |
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.
Shouldn't we just test all the bytes? It is small enough.
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.
Should we also test wide string literals etc?
@@ -858,8 +858,8 @@ bool ByteCodeExprGen<Emitter>::VisitStringLiteral(const StringLiteral *E) { | |||
|
|||
// If the initializer string is too long, a diagnostic has already been | |||
// emitted. Read only the array length from the string literal. | |||
unsigned N = | |||
std::min(unsigned(CAT->getSize().getZExtValue()), E->getLength()); | |||
unsigned ArraySize = CAT->getSize().getZExtValue(); |
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.
So getZExtValue()
returns uint64_t
yet we are using unsigned
. I know this is already an existing problem that we make varying assumptions in different places but I am wondering what the long-term plan is for this this. Forgive me if I have asked this question in another context and I just forgot.
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.
It's a bit tricky since StringLiteral::getLength()
returns unsigned
again, so we can't use the extra bytes anyway and need to cast to unsigned
for the std::min()
.
270735d
to
f2b9dec
Compare
No description provided.