Bug 56358 - [C++11] Erroneous interaction of typedef and inherited constructor declarations
Summary: [C++11] Erroneous interaction of typedef and inherited constructor declarations
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: 4.8.0
Assignee: Jason Merrill
URL:
Keywords: rejects-valid
: 56452 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-02-16 21:10 UTC by Daniel Krügler
Modified: 2013-02-27 18:15 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-02-20 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Krügler 2013-02-16 21:10:55 UTC
The following code - compiled with the flags

-pedantic-errors -std=c++11 -Wall

is rejected by gcc 4.8.0 20130210 (experimental):

//----------------------------------
template<class T>
struct A {};

template<class T>
struct B1 : A<T> {
  typedef A<T> super_t;
  using A<T>::A; // #7
};

template<class T>
struct B2 : A<T> {
  using A<T>::A;
  typedef A<T> super_t; // #13
};
//----------------------------------

"7|error: declaration of 'using A<T>::A' [-fpermissive]|
2|error: changes meaning of 'A' from 'struct A<T>' [-fpermissive]|
13|error: 'A' does not name a type|
13|note: (perhaps 'typename A<T>::A' was intended)"

It could be related to bug 56323, but I have currently no way to verify this hypotheses.

My understanding is that both definitions of B1 and B2 should be valid. Note that even though the typedefs referring to A<T> are needed to produce the error, even though at least in B1 its effects are completely unexpected.
Comment 1 Daniel Krügler 2013-02-20 12:09:13 UTC
As of the more recent trunk gcc 4.8.0 20130217 (experimental) these problems have been partially reolved. Template B1 is now accepted, but template B2 still causes problems. The reduced test case is:

//----------------------------------
template<class T>
struct A {};

template<class T>
struct B : A<T> {
  using A<T>::A;
  typedef A<T> super_t; // #7
};
//----------------------------------

"7|error: 'A' does not name a type|
7|note: (perhaps 'typename A<T>::A' was intended)"
Comment 2 Jason Merrill 2013-02-26 18:04:27 UTC
*** Bug 56452 has been marked as a duplicate of this bug. ***
Comment 3 Jason Merrill 2013-02-27 18:13:36 UTC
Author: jason
Date: Wed Feb 27 18:13:24 2013
New Revision: 196316

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=196316
Log:
	PR c++/56358
	PR c++/56323
	* name-lookup.c (do_class_using_decl): Use ctor_identifier instead
	of the base name for inheriting ctors.
	(push_class_level_binding_1): Remove inheriting ctor handling.
	* pt.c (tsubst_decl) [USING_DECL]: Likewise.
	* class.c (add_implicitly_declared_members): Adjust.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/inh-ctor18.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/class.c
    trunk/gcc/cp/name-lookup.c
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/g++.dg/inherit/using5.C
    trunk/gcc/testsuite/g++.old-deja/g++.other/using3.C
Comment 4 Jason Merrill 2013-02-27 18:15:02 UTC
Fixed.