Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

array-bounds warnigns building clang with gcc 4.9.1 #23709

Closed
llvmbot opened this issue Apr 24, 2015 · 9 comments
Closed

array-bounds warnigns building clang with gcc 4.9.1 #23709

llvmbot opened this issue Apr 24, 2015 · 9 comments
Labels
bugzilla Issues migrated from bugzilla cmake Build system in general and CMake in particular

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 24, 2015

Bugzilla Link 23335
Resolution FIXED
Resolved on Jun 10, 2017 12:35
Version trunk
OS Windows NT
Reporter LLVM Bugzilla Contributor
CC @chandlerc,@zygoloid

Extended Description

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;
^

@zygoloid
Copy link
Mannequin

zygoloid mannequin commented Apr 24, 2015

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.)

@llvmbot
Copy link
Collaborator Author

llvmbot commented Apr 24, 2015

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

@zygoloid
Copy link
Mannequin

zygoloid mannequin commented Apr 24, 2015

OK, in the absence of any evidence of a real bug here, I think we should turn off this warning when building with GCC.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Apr 24, 2015

@zygoloid
Copy link
Mannequin

zygoloid mannequin commented Apr 24, 2015

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.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Apr 28, 2015

Turn off warning for g++

@chandlerc
Copy link
Member

Created attachment 14262 [details]
Turn off warning for g++

As always, please send patches to the commits list rather than updating isolated bugs.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Apr 28, 2015

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::ArrayRefllvm::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]

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jun 10, 2017

too old, closing

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla cmake Build system in general and CMake in particular
Projects
None yet
Development

No branches or pull requests

2 participants