This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/56452] New: [C++11] Using declaration for inheriting constructors taints template parameter
- From: "lucdanton at free dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 26 Feb 2013 01:30:17 +0000
- Subject: [Bug c++/56452] New: [C++11] Using declaration for inheriting constructors taints template parameter
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56452
Bug #: 56452
Summary: [C++11] Using declaration for inheriting constructors
taints template parameter
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: lucdanton@free.fr
Created attachment 29537
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29537
Minimal reproducible testcase
$ g++-snapshot --version
g++-snapshot (Debian 20130222-1) 4.8.0 20130223 (experimental) [trunk revision
196236]
$ cat main.cpp
struct foo {
explicit foo(int) {}
};
template<typename T>
struct bar: T {
using T::T;
// Bad
explicit bar(): T(0) {}
void baz()
{
// Also bad
using qux = T;
}
};
int main()
{}
$ g++-snapshot -std=c++11 -pthread main.cpp
main.cpp: In constructor 'bar<T>::bar()':
main.cpp:10:21: error: 'using T::T' is not a non-static data member of 'bar<T>'
explicit bar(): T(0) {}
^
main.cpp: In member function 'void bar<T>::baz()':
main.cpp:15:21: error: expected type-specifier before 'T'
using qux = T;
^
---
If the using declaration is commented out, then things proceed as usual. It is
also possible to alias the template parameter before the using declaration
(e.g. using base_type = T;) to substitute for uses of T after the declaration.
Because this doesn't happen if bar is not a template, I don't think it is
intended.