[flang-commits] [PATCH] D133693: [flang][runtime] ensure character compares to blank are unsigned

Pete Steinfeld via Phabricator via flang-commits flang-commits at lists.llvm.org
Mon Sep 12 08:53:12 PDT 2022


PeteSteinfeld accepted this revision.
PeteSteinfeld added a comment.
This revision is now accepted and ready to land.

Other than my comment about repeated code, all build, tests, and looks good.



================
Comment at: flang/runtime/character.cpp:25-29
   for (; chars-- > 0; ++x) {
-    if (*x < ' ') {
+    if (*reinterpret_cast<const UNSIGNED_CHAR *>(x) < blank) {
       return -1;
     }
+    if (*reinterpret_cast<const UNSIGNED_CHAR *>(x) > blank) {
----------------
You could avoid some repeated code here:
```
    UNSIGNED_CHAR ux = *reinterpret_cast<const UNSIGNED_CHAR *>(x);
    if (ux < blank) {
      return -1;
    }
    if (ux > blank) {

```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133693/new/

https://reviews.llvm.org/D133693



More information about the flang-commits mailing list