| Issue |
53007
|
| Summary |
Warnings when building with gcc like array subscript 4294967295 is above array bounds and others
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
mulle-nat
|
I get a lot of the following warnings, when I am building `release/13.x` (specifically [67b5bc26bde81a60688ae5c049a001ffbc6dd614](https://github.com/llvm/llvm-project/commit/67b5bc26bde81a60688ae5c049a001ffbc6dd614) with the standard gcc 11.2.0 on Ubuntu 21.10 :
``` console
/home/src/srcL/llvm-130/llvm/include/llvm/ADT/SparseBitVector.h: In member function ‘llvm::Error llvm::pdb::PDBFileBuilder::finalizeMsfLayout()’:
/home/src/srcL/llvm-130/llvm/include/llvm/ADT/SparseBitVector.h:138:15: warning: array subscript 4294967295 is above array bounds of ‘const BitWord [2]’ {aka ‘const long unsigned int [2]’} [-Warray-bounds]
138 | if (Bits[Idx] != 0)
| ~~~~^
/home/src/srcL/llvm-130/mulle-clang-project/llvm/include/llvm/ADT/SparseBitVector.h:54:11: note: while referencing ‘llvm::SparseBitVectorElement<128>::Bits’
54 | BitWord Bits[BITWORDS_PER_ELEMENT];
[2067/5633] Building CXX object lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/MachineModuleInfo.cpp.o
In constructor ‘llvm::MachineModuleInfo::MachineModuleInfo(const llvm::LLVMTargetMachine*)’,
inlined from ‘llvm::MachineModuleInfoWrapperPass::MachineModuleInfoWrapperPass(const llvm::LLVMTargetMachine*)’ at /home/src/srcL/llvm-130/llvm/lib/CodeGen/MachineModuleInfo.cpp:357:26,
inlined from ‘llvm::Pass* llvm::callDefaultCtor() [with PassName = llvm::MachineModuleInfoWrapperPass]’ at /home/src/srcL/llvm-130/llvm/include/llvm/PassSupport.h:80:76:
/home/src/srcL/llvm-130/llvm/lib/CodeGen/MachineModuleInfo.cpp:240:51: warning: ‘this’ pointer is null [-Wnonnull]
240 | Context.setObjectFileInfo(TM->getObjFileLowering());
| ~~~~~~~~~~~~~~~~~~~~~~^~
[2133/5633] Building CXX object projects/compiler-rt/lib/asan/CMakeFiles/RTAsan.x86_64.dir/asan_interceptors.cpp.o
In file included from /home/src/srcL/llvm-130/compiler-rt/lib/asan/asan_interceptors.cpp:174:
/home/src/srcL/llvm-130/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:7049:51: warning: ISO C++11 requires at least one argument for the "..." in a variadic macro
7049 | STRXFRM_INTERCEPTOR_IMPL(strxfrm, dest, src, len);
| ^
/home/src/srcL/llvm-130/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:6950:18: warning: ‘int mcheck(void (*)(int))’ specifies less restrictive attribute than its target ‘int __interceptor_mcheck(void (*)(int))’: ‘nothrow’ [-Wmissing-attributes]
6950 | INTERCEPTOR(int, mcheck, void (*abortfunc)(int mstatus)) {
[2639/5633] Building CXX object lib/Object/CMakeFiles/LLVMObject.dir/Archive.cpp.o
In file included from /home/src/srcL/llvm-130/llvm/lib/Object/Archive.cpp:13:
In constructor ‘llvm::object::Archive::ChildFallibleIterator::ChildFallibleIterator(const llvm::object::Archive::Child&)’,
inlined from ‘llvm::object::Archive::child_iterator llvm::object::Archive::child_end() const’ at /home/src/srcL/llvm-130/llvm/lib/Object/Archive.cpp:799:29:
/home/src/srcL/llvm-130/llvm/include/llvm/Object/Archive.h:147:45: warning: ‘*(uint16_t*)((char*)&<unnamed> + offsetof(llvm::object::Archive::Child, llvm::object::Archive::Child::StartOfFile))’ is used uninitialized [-Wuninitialized]
147 | ChildFallibleIterator(const Child &C) : C(C) {}
llvm/ADT/StringRef.h:319:37,
inlined from ‘bool llvm::getConstantStringInfo(const llvm::Value*, llvm::StringRef&, uint64_t, bool)’ at /home/src/srcL/llvm-130/llvm/lib/Analysis/ValueTracking.cpp:4217:21:
/usr/include/string.h:86:27: warning: ‘void* __builtin_memchr(const void*, int, long unsigned int)’ specified bound 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overread]
86 | return __builtin_memchr (__s, __c, __n);
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
[3000/5633] Building CXX object lib/DWP/CMakeFiles/LLVMDWP.dir/DWP.cpp.o
In file included from /home/src/srcL/llvm-130/llvm/include/llvm/DWP/DWP.h:4,
from /home/src/srcL/llvm-130/llvm/lib/DWP/DWP.cpp:13:
In static member function ‘static bool llvm::DWPStringPool::CStrDenseMapInfo::isEqual(const char*, const char*)’,
inlined from ‘bool llvm::DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT, BucketT>::LookupBucketFor(const LookupKeyT&, const BucketT*&) const [with LookupKeyT = const char*; DerivedT = llvm::DenseMap<const char*, unsigned int, llvm::DWPStringPool::CStrDenseMapInfo>; KeyT = const char*; ValueT = unsigned int; KeyInfoT = llvm::DWPStringPool::CStrDenseMapInfo; BucketT = llvm::detail::DenseMapPair<const char*, unsigned int>]’ at /home/src/srcL/llvm-130/llvm/include/llvm/ADT/DenseMap.h:631:11,
inlined from ‘bool llvm::DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT, BucketT>::LookupBucketFor(const LookupKeyT&, BucketT*&) [with LookupKeyT = const char*; DerivedT = llvm::DenseMap<const char*, unsigned int, llvm::DWPStringPool::CStrDenseMapInfo>; KeyT = const char*; ValueT = unsigned int; KeyInfoT = llvm::DWPStringPool::CStrDenseMapInfo; BucketT = llvm::detail::DenseMapPair<const char*, unsigned int>]’ at /home/src/srcL/llvm-130/llvm/include/llvm/ADT/DenseMap.h:662:24,
inlined from ‘BucketT* llvm::DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT, BucketT>::InsertIntoBucketImpl(const KeyT&, const LookupKeyT&, BucketT*) [with LookupKeyT = const char*; DerivedT = llvm::DenseMap<const char*, unsigned int, llvm::DWPStringPool::CStrDenseMapInfo>; KeyT = const char*; ValueT = unsigned int; KeyInfoT = llvm::DWPStringPool::CStrDenseMapInfo; BucketT = llvm::detail::DenseMapPair<const char*, unsigned int>]’ at /home/src/srcL/llvm-130/llvm/include/llvm/ADT/DenseMap.h:582:22,
inlined from ‘BucketT* llvm::DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT, BucketT>::InsertIntoBucket(BucketT*, KeyArg&&, ValueArgs&& ...) [with KeyArg = const char*; ValueArgs = {unsigned int}; DerivedT = llvm::DenseMap<const char*, unsigned int, llvm::DWPStringPool::CStrDenseMapInfo>; KeyT = const char*; ValueT = unsigned int; KeyInfoT = llvm::DWPStringPool::CStrDenseMapInfo; BucketT = llvm::detail::DenseMapPair<const char*, unsigned int>]’ at /home/src/srcL/llvm-130/llvm/include/llvm/ADT/DenseMap.h:547:37,
inlined from ‘std::pair<llvm::DenseMapIterator<KeyT, ValueT, KeyInfoT, BucketT>, bool> llvm::DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT, BucketT>::try_emplace(KeyT&&, Ts&& ...) [with Ts = {unsigned int}; DerivedT = llvm::DenseMap<const char*, unsigned int, llvm::DWPStringPool::CStrDenseMapInfo>; KeyT = const char*; ValueT = unsigned int; KeyInfoT = llvm::DWPStringPool::CStrDenseMapInfo; BucketT = llvm::detail::DenseMapPair<const char*, unsigned int>]’ at /home/src/srcL/llvm-130/llvm/include/llvm/ADT/DenseMap.h:234:25,
inlined from ‘std::pair<llvm::DenseMapIterator<KeyT, ValueT, KeyInfoT, BucketT>, bool> llvm::DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT, BucketT>::insert(std::pair<_Tp1, _Tp2>&&) [with DerivedT = llvm::DenseMap<const char*, unsigned int, llvm::DWPStringPool::CStrDenseMapInfo>; KeyT = const char*; ValueT = unsigned int; KeyInfoT = llvm::DWPStringPool::CStrDenseMapInfo; BucketT = llvm::detail::DenseMapPair<const char*, unsigned int>]’ at /home/src/srcL/llvm-130/llvm/include/llvm/ADT/DenseMap.h:215:23,
inlined from ‘uint32_t llvm::DWPStringPool::getOffset(const char*, unsigned int)’ at /home/src/srcL/llvm-130/llvm/include/llvm/DWP/DWPStringPool.h:44:28,
inlined from ‘void llvm::writeStringsAndOffsets(llvm::MCStreamer&, llvm::DWPStringPool&, llvm::MCSection*, llvm::StringRef, llvm::StringRef, uint16_t)’ at /home/src/srcL/llvm-130/llvm/lib/DWP/DWP.cpp:370:26:
/home/src/srcL/llvm-130/llvm/include/llvm/DWP/DWPStringPool.h:29:20: warning: ‘int strcmp(const char*, const char*)’ reading 1 or more bytes from a region of size 0 [-Wstringop-overread]
29 | return strcmp(LHS, RHS) == 0;
In destructor ‘llvm::APInt::~APInt()’,
inlined from ‘llvm::APSInt::~APSInt()’ at /home/src/srcL/llvm-130/llvm/include/llvm/ADT/APSInt.h:22:22,
inlined from ‘bool checkOMPArraySectionConstantForReduction(clang::ASTContext&, const clang::OMPArraySectionExpr*, bool&, llvm::SmallVectorImpl<llvm::APSInt>&)’ at /home/src/srcL/llvm-130/clang/lib/Sema/SemaOpenMP.cpp:16672:45,
inlined from ‘bool actOnOMPReductionKindClause(clang::Sema&, {anonymous}::DSAStackTy*, clang::OpenMPClauseKind, llvm::ArrayRef<clang::Expr*>, clang::SourceLocation, clang::SourceLocation, clang::SourceLocation, clang::SourceLocation, clang::CXXScopeSpec&, const clang::DeclarationNameInfo&, llvm::ArrayRef<clang::Expr*>, {anonymous}::ReductionData&)’ at /home/src/srcL/llvm-130/clang/lib/Sema/SemaOpenMP.cpp:17030:68:
/home/src/srcL/llvm-130/llvm/include/llvm/ADT/APInt.h:333:18: warning: ‘void operator delete [](void*)’ called on a pointer to an unallocated object ‘1’ [-Wfree-nonheap-object]
333 | delete[] U.pVal;
| ^~~~
```
I am having some problems with clang at the moment (probably another bug report) but some of these warnings look like bugs, so maybe its related to my problems.
Here is how I build it (none of the variables were set):
``` bash
[ ! -d build ] && mkdir build
cd build &&
cmake \
-DLLVM_ENABLE_PROJECTS="libcxxabi;libcxx;compiler-rt;clang" \
-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" \
-DCMAKE_EXE_LINKER_FLAGS="-Wl,--reduce-memory-overheads" \
-DCMAKE_INSTALL_PREFIX="${PREFIX:-/opt}/llvm/${NAME:-13.0.1.0}" \
-DCMAKE_INSTALL_MESSAGE='LAZY' \
-G Ninja \
${CMAKEFLAGS} \
../llvm &&
ninja ${NINJAFLAGS} "$@"
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs