https://llvm.org/bugs/show_bug.cgi?id=31607
Bug ID: 31607 Summary: Clang accepts invalid code that mutates a const parameter when it is defined with a 'const' qualifier but declared without the 'const' in a class template Product: clang Version: trunk Hardware: PC OS: All Status: NEW Severity: normal Priority: P Component: C++ Assignee: unassignedclangb...@nondot.org Reporter: arpha...@gmail.com CC: dgre...@apple.com, llvm-bugs@lists.llvm.org Classification: Unclassified Clang fails to report an error that it "cannot assign to variable 'b' with const-qualified type" given the following piece of code: template<class T = int> struct A { struct B {}; const B* test (const B* b) const; }; template<class T> inline auto A< T >::test (const B* const b) const -> const B* { return ++b; // expected an error here } int main() { A<> m; const A<>::B* b = 0; b = m.test (b); } The AST dumps show that the specialisation of method test from class A has the following parameter declaration: ParmVarDecl 0x7fba11802228 <col:17, col:26> col:26 used b 'const struct A<int>::B *' but the non-specialised definition of the method test has the following parameter declaration: ParmVarDecl 0x7fba11800e90 <col:27, col:42> col:42 referenced b 'const struct A::B *const' This makes me think that the error isn't reported because the 'const' qualifier isn't given to the parameter in the specialised method definition. -- 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