[LLVMdev] Warnings when compiling llvm+clang (Mac OS X system gcc)

Filipe Cabecinhas filcab at gmail.com
Thu Jan 20 03:37:41 PST 2011


Hi,


There are some warnings in the LLVM and clang code bases:


----------------------------
llvm[0]: Compiling RegAllocGreedy.cpp for Release+Asserts build
/Users/filcab/dev/stuff/llvm/llvm/include/llvm/ADT/SmallVector.h: In member function ‘void<unnamed>::RAGreedy::calcLiveBlockInfo(llvm::LiveInterval&)’:
/Users/filcab/dev/stuff/llvm/llvm/include/llvm/ADT/SmallVector.h:325: warning: ‘BC.llvm::SpillPlacement::BlockConstraint::Exit’ is used uninitialized in this function
----------------------------
^^ The error repeats several times.


It seems the error occurs when push_back copies the received object, which is a struct:
struct BlockConstraint {
unsigned Number; ///< Basic block number (from MBB::getNumber()).
BorderConstraint Entry : 8; ///< Constraint on block entry.
BorderConstraint Exit : 8; ///< Constraint on block exit.
};



Where only the Number member is initialized. Couldn't we initialize the other members to invalid values?


In clang, the warning is:


----------------------------
makellvm[0]: Compiling SemaTemplateVariadic.cpp for Release+Asserts build
/Users/filcab/dev/stuff/llvm/llvm/tools/clang/lib/Sema/SemaTemplateVariadic.cpp: In member function ‘bool clang::Sema::CheckParameterPacksForExpansion(clang::SourceLocation, clang::SourceRange, const clang::UnexpandedParameterPack*, unsigned int, const clang::MultiLevelTemplateArgumentList&, bool&, bool&, llvm::Optional<unsigned int>&)’:
/Users/filcab/dev/stuff/llvm/llvm/tools/clang/lib/Sema/SemaTemplateVariadic.cpp:479: warning: ‘Index’ may be used uninitialized in this function
/Users/filcab/dev/stuff/llvm/llvm/tools/clang/lib/Sema/SemaTemplateVariadic.cpp:478: warning: ‘Depth’ may be used uninitialized in this function
----------------------------



It seems the problem gcc is seeing is:


the dyn_cast to cons TemplateTypeParmType fails
isa<ParlVarDecl>(ND) is true
Instantiation && Instantiation->is<DeclArgumentPack *>() is true
CurrentInstantiationScope->getPartiallySubstitutedPack() is true


I don't know enough about clang to know how feasible this path is, so I defer to this list.




BTW, clang++ doesn't warn about any of these "problems" (by using make CXX=clang++)


Regards,


Filipe Cabecinhas



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110120/8bfebad3/attachment.html>


More information about the llvm-dev mailing list