Luke A. Guest via llvm-dev
2020-Sep-05 11:50 UTC
[llvm-dev] include/llvm/ADT/SmallVector.h:491:7: warning: array subscript 1 is outside array bounds of ‘char [1]’ [-Warray-bounds]
Hi, Built llvm/clang 10.0.1 on Gentoo today and got the folowing error building clang: * LLVM_BUILD_TESTS * QA Notice: Package triggers severe warnings which indicate that it * may exhibit random runtime failures. * /usr/lib/llvm/10/include/llvm/ADT/SmallVector.h:491:7: warning: array subscript 1 is outside array bounds of ‘char [1]’ [-Warray-bounds] * /usr/lib/llvm/10/include/llvm/ADT/SmallVector.h:491:7: warning: array subscript 1 is outside array bounds of ‘clang::CanQualType [1]’ {aka ‘clang::CanQual<clang::Type> [1]’} [-Warray-bounds] * /usr/lib/llvm/10/include/llvm/ADT/SmallVector.h:491:7: warning: array subscript 1 is outside array bounds of ‘char [1]’ [-Warray-bounds] * /usr/lib/llvm/10/include/llvm/ADT/SmallVector.h:491:7: warning: array subscript 1 is outside array bounds of ‘clang::CanQualType [1]’ {aka ‘clang::CanQual<clang::Type> [1]’} [-Warray-bounds] * /usr/lib/llvm/10/include/llvm/ADT/SmallVector.h:491:7: warning: array subscript 1 is outside array bounds of ‘char [1]’ [-Warray-bounds] * Please do not file a Gentoo bug and instead report the above QA * issues directly to the upstream developers of this software. * Homepage: https://llvm.org/ strip: x86_64-pc-linux-gnu-strip --strip-unneeded -N __gentoo_check_ldflags__ -R .comment -R .GCC.command.line -R .note.gnu.gold-version /usr/lib/llvm/10/bin/pp-trace /usr/lib/llvm/10/bin/diagtool /usr/lib/llvm/10/bin/clang-10 /usr/lib/llvm/10/lib32/libclang.so.10 /usr/lib/llvm/10/lib32/libclang-cpp.so.10 https://bugs.gentoo.org/740456
Dimitry Andric via llvm-dev
2020-Sep-05 21:21 UTC
[llvm-dev] include/llvm/ADT/SmallVector.h:491:7: warning: array subscript 1 is outside array bounds of ‘char [1]’ [-Warray-bounds]
FWIW these are all emitted by recent versions of gcc, for SmallVectorImpl::insert(), in llvm/include/llvm/ADT/SmallVector.h: 513 iterator insert(iterator I, T &&Elt) { 514 if (I == this->end()) { // Important special case for empty vector. 515 this->push_back(::std::move(Elt)); 516 return this->end()-1; 517 } 518 519 assert(I >= this->begin() && "Insertion iterator is out of bounds."); 520 assert(I <= this->end() && "Inserting past the end of the vector."); 521 522 if (this->size() >= this->capacity()) { 523 size_t EltNo = I-this->begin(); 524 this->grow(); 525 I = this->begin()+EltNo; 526 } 527 528 ::new ((void*) this->end()) T(::std::move(this->back())); 529 // Push everything else over. 530 std::move_backward(I, this->end()-1, this->end()); 531 this->set_size(this->size() + 1); 532 533 // If we just moved the element we're inserting, be sure to update 534 // the reference. 535 T *EltPtr = &Elt; 536 if (I <= EltPtr && EltPtr < this->end()) -> 537 ++EltPtr; 538 539 *I = ::std::move(*EltPtr); 540 return I; 541 } For example: In file included from /home/dim/src/llvm/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:14, from /home/dim/src/llvm/llvm-project/llvm/include/llvm/IR/DataLayout.h:22, from /home/dim/src/llvm/llvm-project/llvm/lib/IR/DataLayout.cpp:18: /home/dim/src/llvm/llvm-project/llvm/include/llvm/ADT/SmallVector.h: In member function ‘llvm::Error llvm::DataLayout::setAlignment(llvm::AlignTypeEnum, llvm::Align, llvm::Align, uint32_t)’: /home/dim/src/llvm/llvm-project/llvm/include/llvm/ADT/SmallVector.h:537:7: warning: array subscript 8 is outside array bounds of ‘llvm::LayoutAlignElem [1]’ [-Warray-bounds] 537 | ++EltPtr; | ^~ /home/dim/src/llvm/llvm-project/llvm/lib/IR/DataLayout.cpp:573:68: note: while referencing ‘<anonymous>’ 573 | pref_align, bit_width)); | ^ In file included from /home/dim/src/llvm/llvm-project/llvm/lib/CodeGen/BranchRelaxation.cpp:9: /home/dim/src/llvm/llvm-project/llvm/include/llvm/ADT/SmallVector.h: In member function ‘llvm::MachineBasicBlock* {anonymous}::BranchRelaxation::createNewBlockAfter(llvm::MachineBasicBlock&)’: /home/dim/src/llvm/llvm-project/llvm/include/llvm/ADT/SmallVector.h:537:7: warning: array subscript 1 is outside array bounds of ‘{anonymous}::BranchRelaxation::BasicBlockInfo [1]’ [-Warray-bounds] 537 | ++EltPtr; | ^~ /home/dim/src/llvm/llvm-project/llvm/lib/CodeGen/BranchRelaxation.cpp:213:75: note: while referencing ‘<anonymous>’ 213 | BlockInfo.insert(BlockInfo.begin() + NewBB->getNumber(), BasicBlockInfo()); | ^ In file included from /home/dim/src/llvm/llvm-project/llvm/lib/CodeGen/BranchRelaxation.cpp:9: /home/dim/src/llvm/llvm-project/llvm/include/llvm/ADT/SmallVector.h: In member function ‘virtual bool {anonymous}::BranchRelaxation::runOnMachineFunction(llvm::MachineFunction&)’: /home/dim/src/llvm/llvm-project/llvm/include/llvm/ADT/SmallVector.h:537:7: warning: array subscript 1 is outside array bounds of ‘{anonymous}::BranchRelaxation::BasicBlockInfo [1]’ [-Warray-bounds] 537 | ++EltPtr; | ^~ /home/dim/src/llvm/llvm-project/llvm/lib/CodeGen/BranchRelaxation.cpp:240:75: note: while referencing ‘<anonymous>’ 240 | BlockInfo.insert(BlockInfo.begin() + NewBB->getNumber(), BasicBlockInfo()); | ^ In file included from /home/dim/src/llvm/llvm-project/llvm/include/llvm/CodeGen/ExecutionDomainFix.h:25, from /home/dim/src/llvm/llvm-project/llvm/lib/CodeGen/ExecutionDomainFix.cpp:9: /home/dim/src/llvm/llvm-project/llvm/include/llvm/ADT/SmallVector.h: In member function ‘void llvm::ExecutionDomainFix::visitSoftInstr(llvm::MachineInstr*, unsigned int)’: /home/dim/src/llvm/llvm-project/llvm/include/llvm/ADT/SmallVector.h:566:7: warning: array subscript 1 is outside array bounds of ‘int [1]’ [-Warray-bounds] 566 | ++EltPtr; | ^~ /home/dim/src/llvm/llvm-project/llvm/lib/CodeGen/ExecutionDomainFix.cpp:330:12: note: while referencing ‘rx’ 330 | for (int rx : used) { | ^~ In file included from /home/dim/src/llvm/llvm-project/llvm/include/llvm/ADT/SmallSet.h:18, from /home/dim/src/llvm/llvm-project/llvm/lib/CodeGen/ReachingDefAnalysis.cpp:9: /home/dim/src/llvm/llvm-project/llvm/include/llvm/ADT/SmallVector.h: In member function ‘void llvm::ReachingDefAnalysis::reprocessBasicBlock(llvm::MachineBasicBlock*)’: /home/dim/src/llvm/llvm-project/llvm/include/llvm/ADT/SmallVector.h:566:7: warning: array subscript 1 is outside array bounds of ‘const llvm::ReachingDef [1]’ [-Warray-bounds] 566 | ++EltPtr; | ^~ /home/dim/src/llvm/llvm-project/llvm/lib/CodeGen/ReachingDefAnalysis.cpp:174:59: note: while referencing ‘<anonymous>’ 174 | MBBReachingDefs[MBBNumber][Unit].insert(Start, Def); | ^ I think these are all false positives, but maybe somebody with more knowledge about SmallVectorImpl internals can comment. :) -Dimitry> On 5 Sep 2020, at 13:50, Luke A. Guest via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > Hi, > > Built llvm/clang 10.0.1 on Gentoo today and got the folowing error > building clang: > > * LLVM_BUILD_TESTS > > * QA Notice: Package triggers severe warnings which indicate that it > * may exhibit random runtime failures. > * /usr/lib/llvm/10/include/llvm/ADT/SmallVector.h:491:7: warning: array > subscript 1 is outside array bounds of ‘char [1]’ [-Warray-bounds] > * /usr/lib/llvm/10/include/llvm/ADT/SmallVector.h:491:7: warning: array > subscript 1 is outside array bounds of ‘clang::CanQualType [1]’ {aka > ‘clang::CanQual<clang::Type> [1]’} [-Warray-bounds] > * /usr/lib/llvm/10/include/llvm/ADT/SmallVector.h:491:7: warning: array > subscript 1 is outside array bounds of ‘char [1]’ [-Warray-bounds] > * /usr/lib/llvm/10/include/llvm/ADT/SmallVector.h:491:7: warning: array > subscript 1 is outside array bounds of ‘clang::CanQualType [1]’ {aka > ‘clang::CanQual<clang::Type> [1]’} [-Warray-bounds] > * /usr/lib/llvm/10/include/llvm/ADT/SmallVector.h:491:7: warning: array > subscript 1 is outside array bounds of ‘char [1]’ [-Warray-bounds] > > * Please do not file a Gentoo bug and instead report the above QA > * issues directly to the upstream developers of this software. > * Homepage: https://llvm.org/ > strip: x86_64-pc-linux-gnu-strip --strip-unneeded -N > __gentoo_check_ldflags__ -R .comment -R .GCC.command.line -R > .note.gnu.gold-version > /usr/lib/llvm/10/bin/pp-trace > /usr/lib/llvm/10/bin/diagtool > /usr/lib/llvm/10/bin/clang-10 > /usr/lib/llvm/10/lib32/libclang.so.10 > /usr/lib/llvm/10/lib32/libclang-cpp.so.10 > > > https://bugs.gentoo.org/740456 > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200905/1b36aa30/attachment.html>