[LLVMbugs] [Bug 3900] New: Support/CommandLine.h: Implicit conversion from external storage fails to compile

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Sun Mar 29 04:58:19 PDT 2009


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

           Summary: Support/CommandLine.h: Implicit conversion from external
                    storage fails to compile
           Product: new-bugs
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: fvbommel at wxs.nl
                CC: llvmbugs at cs.uiuc.edu


$ cat test.cpp
#include "llvm/Support/CommandLine.h"

using namespace llvm;

int storage;

static cl::opt<int, true> optimizeLevel("O",
    cl::desc("Optimization level"),
    cl::location(storage));

int getOptLevel() {
    return optimizeLevel;
}


$ g++ test.cpp `llvm-config --cxxflags` -c
/home/urxae/opt/llvm/include/llvm/Support/CommandLine.h: In member function
‘const DataType& llvm::cl::opt_storage<DataType, ExternalStorage,
isClass>::getValue() const [with DataType = int, bool ExternalStorage = true,
bool isClass = false]’:
/home/urxae/opt/llvm/include/llvm/Support/CommandLine.h:864:   instantiated
from ‘llvm::cl::opt<DataType, ExternalStorage, ParserClass>::operator
DataType() const [with DataType = int, bool ExternalStorage = true, ParserClass
= llvm::cl::parser<int>]’
test.cpp:12:   instantiated from here
/home/urxae/opt/llvm/include/llvm/Support/CommandLine.h:779: error: passing
‘const llvm::cl::opt_storage<int, true, false>’ as ‘this’ argument of
‘void llvm::cl::opt_storage<DataType, ExternalStorage, isClass>::check()
[with DataType = int, bool ExternalStorage = true, bool isClass = false]’
discards qualifiers



The obvious fix is to make opt_storage::check() const since it doesn't modify
anything.


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