[llvm-bugs] [Bug 30700] New: partial template specialisation of constness of the decltype of a static const member via operator. yields nonconst
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Oct 14 07:19:45 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=30700
Bug ID: 30700
Summary: partial template specialisation of constness of the
decltype of a static const member via operator. yields
nonconst
Product: clang
Version: 3.8
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++11
Assignee: unassignedclangbugs at nondot.org
Reporter: peter.maucher at arcor.de
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
Classification: Unclassified
Created attachment 17443
--> https://llvm.org/bugs/attachment.cgi?id=17443&action=edit
test case in readable
Hi everyone
at the following example the compiler uses the wrong template specialisation,
as marked by the comments.
/** begin test */
template<typename Test>
struct is_const { const static bool is_constant = false; };
template<typename Test>
struct is_const<const Test> { const static bool is_constant = true; };
class to_test { public: const static unsigned member = 5; };
int main() {
to_test tester;
std::cout << is_const<decltype(tester.member)>::is_constant << " " <<
// =0, should be 1
is_const<decltype(to_test::member)>::is_constant << " " << // =1
std::endl;
//decltype(tester.member) x1 (5);
//decltype(to_test::member) x2(5);
//std::cout << ++x1 << " " << ++x2 << std::endl; // ++x1 fails because
const
}
/** end test */
according to the output of cout, the template resolution fails if I use the
operator. and decltype to get the type, but clang successfully forbids to alter
variables of decltype(tester.member) because it is const-qualified.
I've appended the file in a little more readable and some more tests of
combinations of const and static.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20161014/134e2842/attachment-0001.html>
More information about the llvm-bugs
mailing list