[LLVMbugs] [Bug 21158] New: unsafe mix of type 'bool' and type 'unsigned __int64' in DebugInfo & StringRef

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Oct 4 08:09:38 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=21158

            Bug ID: 21158
           Summary: unsafe mix of type 'bool' and type 'unsigned __int64'
                    in DebugInfo & StringRef
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: yaron.keren at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

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<T>(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<bool>(unsigned int) const' being compiled
          with
          [
              T=bool
          ]


the warning may have merit, when getHeaderFieldAs<bool> instantiates
getAsInteger with T=bool ,the comparison logic

  static_cast<T>(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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20141004/1c991a59/attachment.html>


More information about the llvm-bugs mailing list