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

             Bug #: 14203
           Summary: constexpr of non-integral type does not compile
                    anymore in template function (e.g. libc++'s
                    thread::sleep_for)
           Product: clang
           Version: trunk
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Keywords: regression
          Severity: normal
          Priority: P
         Component: C++11
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected], [email protected],
                    [email protected]
    Classification: Unclassified


The following program fails to compile with clang r166916, even though it
compiled with r166410 (reduced from libc++'s chrono&thread):

struct duration {
    constexpr duration() {}
};


template <typename> // (A) After commenting this line the code compiles
void sleep_for()
{
    constexpr duration max = duration(); // (B)
//    constexpr long max = long(); // (C)    
}


This results in:

% ~/LLVM/build/Release+Asserts/bin/clang++ -c -std=c++11 clang.cpp   
clang.cpp:9:24: error: constexpr variable 'max' must be initialized by a
constant expression
    constexpr duration max = duration();
                       ^     ~~~~~~~~~~
clang.cpp:9:30: note: undefined constructor 'duration' cannot be used in a
constant expression
    constexpr duration max = duration();
                             ^
clang.cpp:1:8: note: declared here
struct duration {
       ^
1 error generated.


When uncommenting line (A) to make "sleep_for" non-templated, the code
compiles. The code also compiles when commenting line (B) and un-commenting
line (C), changing the type of "max" from "duration" to "long".

CC'ing Howard Hinnant, as this bug currently prevents compilation of libc++'s
thread header.

-- 
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to