https://llvm.org/bugs/show_bug.cgi?id=30365
Bug ID: 30365 Summary: Class template member function out-of-line definition dependent parameter uses declaration topmost cv-qualification Product: clang Version: trunk Hardware: PC OS: All Status: NEW Severity: normal Priority: P Component: C++ Assignee: unassignedclangb...@nondot.org Reporter: e...@catmur.co.uk CC: dgre...@apple.com, llvm-bugs@lists.llvm.org Classification: Unclassified In a class template member function out-of-line definition, with a parameter dependent on class template parameters and differing in topmost cv-qualification between declaration and definition, clang uses the parameter type of the declaration rather than the parameter type of the definition, incorrectly accepting this program: template<class T> struct A { void f(typename T::U); }; template<class T> void A<T>::f(typename T::U const i) { i = 1; } // no error struct X { using U = int; }; int main() { A<X>{}.f(0); } Expected error: cannot assign to variable 'i' with const-qualified type 'const typename X::U' (aka 'const int') If the cv-qualifiers are swapped (const present on the declaration, not on the definition), clang incorrectly rejects the program: template<class T> struct A { void f(typename T::U const); }; template<class T> void A<T>::f(typename T::U i) { i = 1; } // error struct X { using U = int; }; int main() { A<X>{}.f(0); } gcc and MSVC compile both these correctly; ICC has the same bug as clang. Tested versions 3.0-3.9. References: [class.mfct]/1, [dcl.fct]/5. -- 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