[flang-commits] [flang] [flang][runtime] Fix another IsContiguous edge case (PR #69199)

Pete Steinfeld via flang-commits flang-commits at lists.llvm.org
Mon Oct 16 07:56:11 PDT 2023


================
@@ -393,13 +393,17 @@ class Descriptor {
     bool stridesAreContiguous{true};
     for (int j{0}; j < leadingDimensions; ++j) {
       const Dimension &dim{GetDimension(j)};
-      stridesAreContiguous &= bytes == dim.ByteStride();
+      stridesAreContiguous &= bytes == dim.ByteStride() | dim.Extent() == 1;
----------------
psteinfeld wrote:

I got compilation warnings on this line.  And because I have warnings treated as errors, the build failed.  Here's the relevant output from the log file:
```
/local/home/psteinfeld/main/jean/flang/include/flang/Runtime/descriptor.h: In member function ‘bool Fortran::runtime::Descriptor::IsContiguous(int) const’:
/local/home/psteinfeld/main/jean/flang/include/flang/Runtime/descriptor.h:396:37: error: suggest parentheses around comparison in operand of ‘|’ [-Werror=parentheses]
  396 |       stridesAreContiguous &= bytes == dim.ByteStride() | dim.Extent() == 1;
      |                               ~~~~~~^~~~~~~~~~~~~~~~~~~
```
To make the warnings go away, I needed to put parentheses around the `bytes ==` and the `dim.Extent() ==` subexpressions.

https://github.com/llvm/llvm-project/pull/69199


More information about the flang-commits mailing list