You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
C:\llvm-clean\include\llvm/ADT/StringRef.h(351): warning C4805: '!=' : unsafe mix of type 'bool' and type 'unsigned __int64' in operation (......\lib\Analysis\ModuleDebugInfoPrinter.cpp) [C:\llvm-clean\msvc\lib\Analysis\LLVMAnalysis.vcxproj]
C:\llvm-clean\include\llvm/IR/DebugInfo.h(200) : see reference to function template instantiation 'bool llvm::Stri
ngRef::getAsInteger(unsigned int,T &) const' being compiled
with
[
T=bool
]
C:\llvm-clean\include\llvm/IR/DebugInfo.h(554) : see reference to function template instantiation 'T llvm::DIDescr
iptor::getHeaderFieldAs(unsigned int) const' being compiled
with
[
T=bool
]
the warning may have merit, when getHeaderFieldAs instantiates getAsInteger with T=bool ,the comparison logic
static_cast(ULLVal) != ULLVal)
which for integers checks if the ULLVal fits in a T sized integer will work somewhat differently for a bool. It will check if ULLVal was 0 or 1 and if not return an error code. This in incosistent with the usual C++ assumption that any non-zero is true.
The text was updated successfully, but these errors were encountered:
Am I right that this warning is coming from StringRef::getAsInteger<bool>()?
If so, the behaviour I expect is: "0" gives false, "1" gives true, anything else is an error. From your description, it sounds like this is what we're getting -- good.
Yup, that should work. You should probably use unsigned long long, since you're in the unsigned code there. Also, add a comment explaining that this is to hide an MSVC warning on bool, or someone is likely to remove the redundant explicit cast in the future.
Extended Description
With trunk r219051 Visual C++ warns:
C:\llvm-clean\include\llvm/ADT/StringRef.h(351): warning C4805: '!=' : unsafe mix of type 'bool' and type 'unsigned __int64' in operation (......\lib\Analysis\ModuleDebugInfoPrinter.cpp) [C:\llvm-clean\msvc\lib\Analysis\LLVMAnalysis.vcxproj]
C:\llvm-clean\include\llvm/IR/DebugInfo.h(200) : see reference to function template instantiation 'bool llvm::Stri
ngRef::getAsInteger(unsigned int,T &) const' being compiled
with
[
T=bool
]
C:\llvm-clean\include\llvm/IR/DebugInfo.h(554) : see reference to function template instantiation 'T llvm::DIDescr
iptor::getHeaderFieldAs(unsigned int) const' being compiled
with
[
T=bool
]
the warning may have merit, when getHeaderFieldAs instantiates getAsInteger with T=bool ,the comparison logic
static_cast(ULLVal) != ULLVal)
which for integers checks if the ULLVal fits in a T sized integer will work somewhat differently for a bool. It will check if ULLVal was 0 or 1 and if not return an error code. This in incosistent with the usual C++ assumption that any non-zero is true.
The text was updated successfully, but these errors were encountered: