[LLVMbugs] [Bug 6243] New: C2440 "reinterpret_cast": cant convert enum to unsigned int

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Fri Feb 5 01:31:38 PST 2010


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

           Summary: C2440 "reinterpret_cast": cant convert enum to unsigned
                    int
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Keywords: compile-fail
          Severity: normal
          Priority: P2
         Component: Support Libraries
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: etherzhhb at gmail.com
                CC: llvmbugs at cs.uiuc.edu


hi all,

i am write to report the "bits_storage" of commandline library not work on msvc
and cygwin.

i am writing the code like this:

enum PrintStyle {  AnalOnly,  PostOder, HierNode,  NameOnly };

cl::bits<enum PrintStyle>
printStyle("print-region-style", cl::Hidden,
           cl::desc("print style of printing out regions"),
           cl::values(
           clEnumValN(AnalOnly, "analyze-only", "only print region on
analyze"),
           clEnumValN(PostOder, "postoder",     "print RegionNodes in post
order"),
           clEnumValN(HierNode, "hier-node",             "print RegionNodes
with hierachical iterator"),
           clEnumValN(NameOnly, "name-only",      "only print the region
name"),
           clEnumValEnd));

and some place have the code like

printStyle.isSet(NameOnly)

then it get a compile error when i compile it with msvc:

error C2440: “reinterpret_cast”: cant convert “const llvm::PrintStyle”
to “unsigned int”   
F:\cygwin\home\ether\polyllvm\pofl\include\llvm\Support\CommandLine.h    1171

and it also cant compile under cygwin:

llvm[0]: Compiling RegionPrinter.cpp for Debug build
/home/ether/polyllvm/pofl/include/llvm/Support/CommandLine.h: In static member
function ‘static unsigned int llvm::cl::bits_storage<DataType,
bool>::Bit(const T&) [with T = llvm::PrintStyle, DataType =
llvm::PrintStyle]’:
/home/ether/polyllvm/pofl/include/llvm/Support/CommandLine.h:1187:  
instantiated from ‘bool llvm::cl::bits_storage<DataType, bool>::isSet(const
T&) [with T = llvm::PrintStyle, DataType = llvm::PrintStyle]’
/home/ether/polyllvm/pofl/lib/Analysis/Region/RegionPrinter.cpp:83:  
instantiated from here
/home/ether/polyllvm/pofl/include/llvm/Support/CommandLine.h:1171: error:
invalid cast from type ‘llvm::PrintStyle’ to type ‘unsigned int’
make: ***
[/home/ether/polyllvm/build/lib/Analysis/Region/Debug/RegionPrinter.o] Error 1

my gcc version is:
gcc version 4.3.4 20090804 (release) 1 (GCC)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------

and  if i use (unsigned) instead of reinterpret_cast, it work.

--best regards
ether


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list