[LLVMbugs] [Bug 13331] New: diagnostic when throwing exceptions	from constexpr
    bugzilla-daemon at llvm.org 
    bugzilla-daemon at llvm.org
       
    Wed Jul 11 11:39:27 PDT 2012
    
    
  
http://llvm.org/bugs/show_bug.cgi?id=13331
             Bug #: 13331
           Summary: diagnostic when throwing exceptions from constexpr
           Product: clang
           Version: 3.1
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++11
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: tomasz at grobelny.net
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified
Consider this code:
#include <stdexcept>
constexpr int isvalidid(const char* str)
{
        return (*str)==0 ? true : 'a'<=str[0] && str[0]<='z' &&
isvalidid(str+1);
}
constexpr const char* operator "" _id(const char* str, size_t /*length*/)
{
    return isvalidid(str) ? str : throw std::logic_error("identifier must
contain only small latin letters");
}
int main()
{
        auto myId="qwWe"_id;
}
Compilation produces:
terminate called after throwing an instance of 'std::logic_error'
  what():  identifier must contain only small latin letters
Aborted
Line number (of the last but one line) would be a welcome addition.
BTW, is there a better way to achieve compile-time string validation?
-- 
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