[flang-commits] [flang] [flang] Produce warning instead of error when bound checking arrays (PR #83011)

Michael Klemm via flang-commits flang-commits at lists.llvm.org
Mon Feb 26 11:15:06 PST 2024


mjklemm wrote:

> ugh, if `dbl_mb` triggers this then all of NWChem is broken with bounds checking.

NWChem does not trigger the warning, as the compiler is not smart enough.  But that does not mean the problem does not exist.  So, yes, the problem is there for NWChem and it is badly UB all over the place.


> @klausler for context, `dbl_mb` is used to implement a heap allocator. it's a common block member and C code increases the size of it, in spite of its declaration. the whole thing is trash but rewriting to use `allocate` would take years.
> 
> in theory, we can increase the size by some amount that makes it much harder for the compiler to prove OOB errors (that aren't really errors, thanks to C) but i don't know how well this will work.

So, even though the problem does not show up, I'd argue that a less harsh reaction of Flang on case where it can detect that seems useful, given that other compilers are either completely silent about this detectable case (ifort, ifx) or prefer to warn (gfortran).



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


More information about the flang-commits mailing list