Skip to content

Commit 2a77441

Browse files
author
serge-sans-paille
committed
Do not dereference an array out of bound just to take its address
This is UB by the standard, and caught by the libstdc++ asserts Differential Revision: https://reviews.llvm.org/D87892
1 parent 095f6fb commit 2a77441

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

flang/lib/Parser/token-sequence.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ TokenSequence &TokenSequence::ToLowerCase() {
160160
std::size_t atToken{0};
161161
for (std::size_t j{0}; j < chars;) {
162162
std::size_t nextStart{atToken + 1 < tokens ? start_[++atToken] : chars};
163-
char *p{&char_[j]}, *limit{&char_[nextStart]};
163+
char *p{&char_[j]};
164+
char const *limit{char_.data() + nextStart};
164165
j = nextStart;
165166
if (IsDecimalDigit(*p)) {
166167
while (p < limit && IsDecimalDigit(*p)) {

0 commit comments

Comments
 (0)