[LLVMbugs] [Bug 10314] New: "bitset::operator[](size_t) const" does not return bool
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sat Jul 9 02:42:07 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=10314
Summary: "bitset::operator[](size_t) const" does not return
bool
Product: libc++
Version: unspecified
Platform: Macintosh
OS/Version: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
AssignedTo: hhinnant at apple.com
ReportedBy: jonathan.sauer at gmx.de
CC: llvmbugs at cs.uiuc.edu
The following program does not compile with clang r134322 and libc++ r134357:
#include <bitset>
template <typename>
struct Foo;
template <> struct Foo<bool> {
static const bool value = true;
};
template <typename B>
static void bar(B)
{
Foo<B>::value;
}
int main(int, char**)
{
std::bitset<32> const bits;
bar(bits[0]);
}
This results in:
$ clang -std=c++0x -stdlib=libc++ clang.cpp
clang.cpp:13:2: error: implicit instantiation of undefined template
'Foo<std::__1::__bit_const_reference<std::__1::__bitset<1, 32> > >'
Foo<B>::value;
^
clang.cpp:20:2: note: in instantiation of function template specialization
'bar<std::__1::__bit_const_reference<std::__1::__bitset<1, 32> > >'
requested here
bar(bits[0]);
^
clang.cpp:4:8: note: template is declared here
struct Foo;
^
1 error generated.
According to 20.5p1, the signature of "operator[](std::size_t) const" is:
constexpr bool operator[](size_t pos) const;
libc++'s bitset's current implementation's signature is:
const_reference operator[](size_t) const,
where "const_reference" is equal to "__bit_const_reference<...>". While it is
implicitely convertible to bool, it is not a bool itself and thus creates
problems when used as a template parameter as in the code above.
--
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