Bug ID: 30700
           Summary: partial template specialisation of constness of the
                    decltype of a static const member via operator. yields
           Product: clang
           Version: 3.8
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
    Classification: Unclassified

Created attachment 17443
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
        //decltype(tester.member)  x1 (5); 
        //decltype(to_test::member) x2(5);
        //std::cout << ++x1 << " " << ++x2 << std::endl; // ++x1 fails because
/** 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

Reply via email to