[LLVMbugs] [Bug 9999] New: A simple recursive TMP static const initializer defeats clang.
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon May 23 18:51:30 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=9999
Summary: A simple recursive TMP static const initializer
defeats clang.
Product: clang
Version: 2.8
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: phorgan1 at gmail.com
CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com
Created an attachment (id=6635)
--> (http://llvm.org/bugs/attachment.cgi?id=6635)
Test program to illustrate the problem built with clang -c testit.cpp
clang version 2.8 (branches/release_28)
Target: i386-pc-linux-gnu
Thread model: posix
This works on gcc but not on clang:
template<unsigned int v>
class bitWidthHolding {
public:
/** width is the number of bits occupied by the template parameter v
*/
static const
unsigned int width = (v == 0 ? 0 : bitWidthHolding<(v >> 1)>::width + 1);
};
static const int width=bitWidthHolding<255>::width;
Error is:
patrick at dell$ clang -c testit.cpp
testit.cpp:7:67: error: in-class initializer is not an integral constant
expression
unsigned int width = (v == 0 ? 0 : bitWidthHolding<(v >> 1)>::width + 1);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
testit.cpp:7:40: note: in instantiation of template class 'bitWidthHolding<0>'
requested here
unsigned int width = (v == 0 ? 0 : bitWidthHolding<(v >> 1)>::width + 1);
^
testit.cpp:7:40: note: in instantiation of template class 'bitWidthHolding<1>'
requested here
unsigned int width = (v == 0 ? 0 : bitWidthHolding<(v >> 1)>::width + 1);
^
testit.cpp:7:40: note: in instantiation of template class 'bitWidthHolding<3>'
requested here
unsigned int width = (v == 0 ? 0 : bitWidthHolding<(v >> 1)>::width + 1);
^
testit.cpp:7:40: note: in instantiation of template class 'bitWidthHolding<7>'
requested here
unsigned int width = (v == 0 ? 0 : bitWidthHolding<(v >> 1)>::width + 1);
^
testit.cpp:7:40: note: in instantiation of template class 'bitWidthHolding<15>'
requested here
unsigned int width = (v == 0 ? 0 : bitWidthHolding<(v >> 1)>::width + 1);
^
testit.cpp:7:40: note: in instantiation of template class 'bitWidthHolding<31>'
requested here
unsigned int width = (v == 0 ? 0 : bitWidthHolding<(v >> 1)>::width + 1);
^
testit.cpp:7:40: note: in instantiation of template class 'bitWidthHolding<63>'
requested here
unsigned int width = (v == 0 ? 0 : bitWidthHolding<(v >> 1)>::width + 1);
^
testit.cpp:7:40: note: in instantiation of template class
'bitWidthHolding<127>'
requested here
unsigned int width = (v == 0 ? 0 : bitWidthHolding<(v >> 1)>::width + 1);
^
testit.cpp:10:24: note: in instantiation of template class
'bitWidthHolding<255>' requested here
static const int width=bitWidthHolding<255>::width;
^
1 error generated.
The real error is the top one, which should be static const int 0, and is not
recognized as const. For us it's a showstopper, we can't use clang because of
this.
--
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