[flang-commits] [flang] 2a77441 - Do not dereference an array out of bound just to take its address

via flang-commits flang-commits at lists.llvm.org
Mon Sep 21 03:08:44 PDT 2020


Author: serge-sans-paille
Date: 2020-09-21T12:08:30+02:00
New Revision: 2a774411174466010c69a2460c81b8d0d4f7165f

URL: https://github.com/llvm/llvm-project/commit/2a774411174466010c69a2460c81b8d0d4f7165f
DIFF: https://github.com/llvm/llvm-project/commit/2a774411174466010c69a2460c81b8d0d4f7165f.diff

LOG: 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

Added: 
    

Modified: 
    flang/lib/Parser/token-sequence.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Parser/token-sequence.cpp b/flang/lib/Parser/token-sequence.cpp
index 4797cb759a72..cdf066dcf777 100644
--- a/flang/lib/Parser/token-sequence.cpp
+++ b/flang/lib/Parser/token-sequence.cpp
@@ -160,7 +160,8 @@ TokenSequence &TokenSequence::ToLowerCase() {
   std::size_t atToken{0};
   for (std::size_t j{0}; j < chars;) {
     std::size_t nextStart{atToken + 1 < tokens ? start_[++atToken] : chars};
-    char *p{&char_[j]}, *limit{&char_[nextStart]};
+    char *p{&char_[j]};
+    char const *limit{char_.data() + nextStart};
     j = nextStart;
     if (IsDecimalDigit(*p)) {
       while (p < limit && IsDecimalDigit(*p)) {


        


More information about the flang-commits mailing list