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: unassignedclangb...@nondot.org
          Reporter: peter.mauc...@arcor.de
                CC: dgre...@apple.com, llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to