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

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Mon Feb 26 12:25:36 PST 2024


klausler wrote:

> I just came across Clang's behavior:
> 
> ```
> /home/micklemm/git/llvm/llvm-project/llvm/include/llvm/ADT/SparseBitVector.h: In member function ‘llvm::Error llvm::pdb::HashTable<ValueT>::load(llvm::BinaryStreamReader&) [with ValueT = llvm::support::detail::packed_endian_specific_integral<unsigned int, llvm::endianness::little, 1>]’:
> /home/micklemm/git/llvm/llvm-project/llvm/include/llvm/ADT/SparseBitVector.h:130:15: warning: array subscript 2 is above array bounds of ‘const BitWord [2]’ {aka ‘const long unsigned int [2]’} [-Warray-bounds]
>   130 |       if (Bits[i] != 0)
>       |           ~~~~^
> /home/micklemm/git/llvm/llvm-project/llvm/include/llvm/ADT/SparseBitVector.h:55:11: note: while referencing ‘llvm::SparseBitVectorElement<128>::Bits’
>    55 |   BitWord Bits[BITWORDS_PER_ELEMENT];
>       |           ^~~~
> ```
> 
> So, Flang behavior would be consistent with its C/C++ counterpart.

Fortran is neither C nor C++.

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


More information about the flang-commits mailing list