LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 23335 - array-bounds warnigns building clang with gcc 4.9.1
Summary: array-bounds warnigns building clang with gcc 4.9.1
Status: RESOLVED FIXED
Alias: None
Product: Build scripts
Classification: Unclassified
Component: cmake (show other bugs)
Version: trunk
Hardware: PC Windows NT
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-23 23:44 PDT by Yaron Keren
Modified: 2017-06-10 12:35 PDT (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments
Turn off array-bounds warning (655 bytes, application/octet-stream)
2015-04-24 13:54 PDT, Yaron Keren
Details
Turn off warning for g++ (691 bytes, application/octet-stream)
2015-04-28 00:12 PDT, Yaron Keren
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Yaron Keren 2015-04-23 23:44:26 PDT
Thread model: posix
gcc version 4.9.1 (i686-posix-dwarf-rev1cee, Built by MinGW-W64 project)

[ 76%] Building CXX object lib/Target/AArch64/CMakeFiles/LLVMAArch64CodeGen.dir/AArch64AddressTypePromotion.cpp.obj
In file included from C:/llvm/tools/clang/include/clang/Basic/PartialDiagnostic.h:19:0,
                 from C:/llvm/tools/clang/include/clang/AST/DeclarationName.h:17,
                 from C:/llvm/tools/clang/include/clang/AST/DeclBase.h:18,
                 from C:/llvm/tools/clang/include/clang/AST/Decl.h:18,
                 from C:/llvm/tools/clang/include/clang/AST/ASTTypeTraits.h:20,
                 from C:/llvm/tools/clang/include/clang/AST/ASTContext.h:18,
                 from C:/llvm/tools/clang/include/clang/Sema/SemaInternal.h:18,
                 from C:/llvm/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp:13:
C:/llvm/tools/clang/include/clang/Basic/Diagnostic.h: In member function 'bool clang::Sema::InstantiatingTemplate::CheckInstantiationDepth(clang::SourceLocation, clang::SourceRange)':
C:/llvm/tools/clang/include/clang/Basic/Diagnostic.h:983:39: warning: array subscript is above array bounds [-Warray-bounds]
     DiagObj->DiagArgumentsKind[NumArgs] = Kind;
                                       ^
C:/llvm/tools/clang/include/clang/Basic/Diagnostic.h:984:40: warning: array subscript is above array bounds [-Warray-bounds]
     DiagObj->DiagArgumentsVal[NumArgs++] = V;
                                        ^
C:/llvm/tools/clang/include/clang/Basic/Diagnostic.h:983:39: warning: array subscript is above array bounds [-Warray-bounds]
     DiagObj->DiagArgumentsKind[NumArgs] = Kind;
                                       ^
C:/llvm/tools/clang/include/clang/Basic/Diagnostic.h:984:40: warning: array subscript is above array bounds [-Warray-bounds]
     DiagObj->DiagArgumentsVal[NumArgs++] = V;
                                        ^
C:/llvm/tools/clang/include/clang/Basic/Diagnostic.h:983:39: warning: array subscript is above array bounds [-Warray-bounds]
     DiagObj->DiagArgumentsKind[NumArgs] = Kind;
                                       ^
C:/llvm/tools/clang/include/clang/Basic/Diagnostic.h:984:40: warning: array subscript is above array bounds [-Warray-bounds]
     DiagObj->DiagArgumentsVal[NumArgs++] = V;
                                        ^
C:/llvm/tools/clang/include/clang/Basic/Diagnostic.h:983:39: warning: array subscript is above array bounds [-Warray-bounds]
     DiagObj->DiagArgumentsKind[NumArgs] = Kind;
                                       ^
C:/llvm/tools/clang/include/clang/Basic/Diagnostic.h:984:40: warning: array subscript is above array bounds [-Warray-bounds]
     DiagObj->DiagArgumentsVal[NumArgs++] = V;
                                        ^
Comment 1 Richard Smith 2015-04-24 10:18:44 PDT
That diagnostic is either useless (it doesn't say which call leads to the invalid array indexing) or wrong (perhaps because GCC unrolled a loop and then determined some late iteration of it would index out of bounds).

Where is the -Warray-bounds coming from? Is this specified by our build system by default, or are you explicitly specifying that? (If the former, we should probably disable it when building with GCC if it's broken.)
Comment 2 Yaron Keren 2015-04-24 10:30:45 PDT
I'm not specifying it, it's all default. The warning appears repeats several more times when included from other source files.

The exact build commands are:

cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE:STRING=Release -DLLVM_DEFAULT_TARGET_TRIPLE=i686-pc-windows-gnu -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_TESTS=ON -DLLVM_INCLUDE_DOCS=OFF -DLLVM_ENABLE_THREADS:BOOL=OFF -DCMAKE_EXE_LINKER_FLAGS="-Wl,--large-address-aware" ..
mingw32-make
Comment 3 Richard Smith 2015-04-24 10:54:41 PDT
OK, in the absence of any evidence of a real bug here, I think we should turn off this warning when building with GCC.
Comment 4 Yaron Keren 2015-04-24 13:54:48 PDT
Created attachment 14254 [details]
Turn off array-bounds warning
Comment 5 Richard Smith 2015-04-24 14:49:31 PDT
CC'ing cmake build system maintainer.

I think this should be guarded by CMAKE_COMPILER_IS_GNUCXX. Clang's -Warray-bounds is not broken in this way.
Comment 6 Yaron Keren 2015-04-28 00:12:02 PDT
Created attachment 14262 [details]
Turn off warning for g++
Comment 7 Chandler Carruth 2015-04-28 00:17:28 PDT
(In reply to comment #6)
> Created attachment 14262 [details]
> Turn off warning for g++

As always, please send patches to the commits list rather than updating isolated bugs.
Comment 8 Yaron Keren 2015-04-28 07:13:09 PDT
Here is the full list of array-bounds warnings with gcc 4.9.1:

Building CXX object lib/Transforms/InstCombine/CMakeFiles/LLVMInstCombine.dir/InstCombinePHI.cpp.obj
c:/llvm/lib/IR/Function.cpp: In function 'std::string llvm::Intrinsic::getName(llvm::Intrinsic::ID, llvm::ArrayRef<llvm::Type*>)':
c:/llvm/lib/IR/Function.cpp:514:30: warning: array subscript is above array bounds [-Warray-bounds]
   std::string Result(Table[id]);
                              ^
[ 79%] Building CXX object lib/Target/ARM/CMakeFiles/LLVMARMCodeGen.dir/ARMAsmPrinter.cpp.obj
In file included from c:/llvm/lib/Target/AArch64/AArch64ISelLowering.h:22:0,
                 from c:/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:14:
c:/llvm/include/llvm/Target/TargetLowering.h: In member function 'void llvm::AArch64TargetLowering::addTypeForNEON(llvm::EVT, llvm::EVT)':
c:/llvm/include/llvm/Target/TargetLowering.h:1317:64: warning: array subscript is above array bounds [-Warray-bounds]
     IndexedModeActions[(unsigned)VT.SimpleTy][IdxMode] &= ~0xf0;
                                                                ^
c:/llvm/include/llvm/Target/TargetLowering.h:1317:64: warning: array subscript is above array bounds [-Warray-bounds]
[ 79%] Building CXX object lib/Target/AArch64/CMakeFiles/LLVMAArch64CodeGen.dir/AArch64InstrInfo.cpp.obj
[ 79%] Building CXX object lib/Target/ARM/CMakeFiles/LLVMARMCodeGen.dir/ARMBaseInstrInfo.cpp.obj
[ 79%] Building CXX object tools/clang/lib/CodeGen/CMakeFiles/clangCodeGen.dir/ItaniumCXXABI.cpp.obj
In file included from c:/llvm/tools/clang/include/clang/Basic/PartialDiagnostic.h:19:0,
                 from c:/llvm/tools/clang/include/clang/AST/DeclarationName.h:17,
                 from c:/llvm/tools/clang/include/clang/AST/DeclBase.h:18,
                 from c:/llvm/tools/clang/include/clang/AST/Decl.h:18,
                 from c:/llvm/tools/clang/include/clang/AST/ASTTypeTraits.h:20,
                 from c:/llvm/tools/clang/include/clang/AST/ASTContext.h:18,
                 from c:/llvm/tools/clang/include/clang/Sema/SemaInternal.h:18,
                 from c:/llvm/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp:13:
c:/llvm/tools/clang/include/clang/Basic/Diagnostic.h: In member function 'bool clang::Sema::InstantiatingTemplate::CheckInstantiationDepth(clang::SourceLocation, clang::SourceRange)':
c:/llvm/tools/clang/include/clang/Basic/Diagnostic.h:983:39: warning: array subscript is above array bounds [-Warray-bounds]
     DiagObj->DiagArgumentsKind[NumArgs] = Kind;
                                       ^
c:/llvm/tools/clang/include/clang/Basic/Diagnostic.h:984:40: warning: array subscript is above array bounds [-Warray-bounds]
     DiagObj->DiagArgumentsVal[NumArgs++] = V;
                                        ^
c:/llvm/tools/clang/include/clang/Basic/Diagnostic.h:983:39: warning: array subscript is above array bounds [-Warray-bounds]
     DiagObj->DiagArgumentsKind[NumArgs] = Kind;
                                       ^
c:/llvm/tools/clang/include/clang/Basic/Diagnostic.h:984:40: warning: array subscript is above array bounds [-Warray-bounds]
     DiagObj->DiagArgumentsVal[NumArgs++] = V;
                                        ^
[ 79%] [ 79%] Building CXX object lib/Target/ARM/MCTargetDesc/CMakeFiles/LLVMARMDesc.dir/ARMAsmBackend.cpp.obj
In file included from c:/llvm/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp:27:0:
c:/llvm/gcc/lib/Target/ARM/ARMGenAsmWriter.inc: In member function 'void llvm::ARMInstPrinter::printInstruction(const llvm::MCInst*, const llvm::MCSubtargetInfo&, llvm::raw_ostream&)':
c:/llvm/gcc/lib/Target/ARM/ARMGenAsmWriter.inc:6115:31: warning: array subscript is below array bounds [-Warray-bounds]

   O << AsmStrs+(Bits & 4095)-1;
                               ^
[ 83%] Building CXX object lib/Target/Mips/MCTargetDesc/CMakeFiles/LLVMMipsDesc.dir/MipsAsmBackend.cpp.obj
In file included from c:/llvm/lib/Target/Hexagon/Hexagon.h:19:0,
                 from c:/llvm/lib/Target/Hexagon/HexagonISelLowering.h:18,
                 from c:/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp:15:
c:/llvm/include/llvm/Target/TargetLowering.h: In member function 'void llvm::HexagonTargetLowering::promoteLdStType(llvm::EVT, llvm::EVT)':
c:/llvm/include/llvm/Target/TargetLowering.h:1287:36: warning: array subscript is above array bounds [-Warray-bounds]
     OpActions[(unsigned)VT.SimpleTy][Op] = (uint8_t)Action;
                                    ^
c:/llvm/include/llvm/Target/TargetLowering.h: In constructor 'llvm::HexagonTargetLowering::HexagonTargetLowering(const llvm::TargetMachine&, const llvm::HexagonSubtarget&)':
c:/llvm/include/llvm/Target/TargetLowering.h:1317:64: warning: array subscript is above array bounds [-Warray-bounds]
     IndexedModeActions[(unsigned)VT.SimpleTy][IdxMode] &= ~0xf0;
                                                                ^
c:/llvm/include/llvm/Target/TargetLowering.h:1317:64: warning: array subscript is above array bounds [-Warray-bounds]
Comment 9 Yaron Keren 2017-06-10 12:35:33 PDT
too old, closing