[LLVMbugs] [Bug 14203] New: constexpr of non-integral type does not compile anymore in template function (e.g. libc++'s thread::sleep_for)
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Oct 29 06:20:36 PDT 2012
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: unassignedclangbugs at nondot.org
ReportedBy: jonathan.sauer at gmx.de
CC: dgregor at apple.com, hhinnant at apple.com,
llvmbugs at cs.uiuc.edu
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.
More information about the llvm-bugs
mailing list