[llvm-bugs] [Bug 30365] New: Class template member function out-of-line definition dependent parameter uses declaration topmost cv-qualification
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Sep 13 04:06:48 PDT 2016
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: unassignedclangbugs at nondot.org
Reporter: ed at catmur.co.uk
CC: dgregor at apple.com, llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160913/626ba817/attachment.html>
More information about the llvm-bugs
mailing list