[LLVMbugs] [Bug 15911] New: User defined constructor lookup fails on local class defined inside template difinition and passed to another template as an template argument
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sun May 5 01:08:19 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=15911
Bug ID: 15911
Summary: User defined constructor lookup fails on local class
defined inside template difinition and passed to
another template as an template argument
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++11
Assignee: unassignedclangbugs at nondot.org
Reporter: boostcpp at gmail.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
Clang fails to lookup user defined constructor of local class which is defined
inside the template definition and passed to class template, or function
template by explicit template argument specification.
For class template:
template < typename T >
struct S
{
T t ;
S() : t(0) { } } ;
} ;
// local class defined inside template definition.
template < typename T >
void f()
{
struct local { local( int ) { } } ;
S<local> s ;
}
// local class defined inside non-template definition.
void g()
{
struct local { local( int ) { } } ;
S<local> s ;
}
int main()
{
f<void>() ; // error: no matching constructor for initialization of 'local'
g() ; // OK, lookup works
}
Expected behavior: constructor lookup success.
Actual behavior: lookup fails.
For function template, only the explicit template argument specification cause
this problem:
template < typename T >
void f( )
{
T x(0) ;
}
template < typename T >
void call_f_template()
{
struct local { local(int) {} } ;
f<local>() ;
}
void call_f()
{
struct local { local(int) {} } ;
f<local>() ;
}
int main()
{
call_f_template<void>() ; // error: no matching constructor for
initialization of 'local'
call_f() ; // OK, lookup works.
}
Interestingly, argument deduction can workaround this problem.
In a context where argument deduction works, explicit template argument
specification also works.
template < typename T >
void f( T const & )
{
T x(0) ;
}
template < typename T >
void call_f_template()
{
struct local { local(int) {} } ;
local obj(0) ;
f( obj ) ; // OK
f<local>( obj ) ; // Also OK
}
int main()
{
call_f_template<void>() ;
}
Only the lookup of user defined constructor fails.
Lookup of implicitly defined constructors works as expected.
--
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/20130505/41054513/attachment.html>
More information about the llvm-bugs
mailing list