This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: c++/3242: Forwarding using 'using' of base members broken? (see also c++/3283)


The following reply was made to PR c++/3242; it has been noted by GNATS.

From: Wolfgang Wander <wwc@rentec.com>
To: gcc-gnats@gcc.gnu.org
Cc: maeder@glue.ch
Subject: Re: c++/3242: Forwarding using 'using' of base members broken? (see also c++/3283)
Date: Wed, 20 Jun 2001 10:13:49 -0400 (EDT)

 >Submitter-Id:	net
 >Originator:    Wolfgang Wander	
 >Organization:	
 >Confidential:	no
 >Synopsis:	Forwarding using 'using' of base members broken?
 >Severity:	serious
 >Priority:	medium
 >Category:	c++
 >Class:		rejects-legal
 >Release:	3.0
 >Environment:
 System: Linux localhost 2.4.3-ac12 #18 Sun Apr 22 23:29:30 EDT 2001 i686 unknown
 System: SunOS localhost 5.7 Generic_106541-12 sun4u sparc SUNW,Ultra-4
 System: any?
 Architecture: sun4
 host: sparc-sun-solaris2.7
 build: sparc-sun-solaris2.7
 target: sparc-sun-solaris2.7
 configured with: /work/external/src/gcc-3.0/configure --prefix=/work/external/ --enable-long-long --enable-languages=c++
 >Description:
         Since the first bug report did not include the full cpp output
 and Thomas' one did neither - here is a one that is standalone and does
 not use the new libstdc++.
 
         A using declaration does not forward all of the overloaded
         member functions. 
  
         KaiCC/SunCC and g++-2.95 (as well as the standard AFAIK) 
         agree that the code below is legal code.
 >How-To-Repeat:
  ---
 template <typename T>
 struct Base {
   typedef T &type;
   typedef const T &const_type;
   type foo();
   const_type foo() const;
 };
 
 struct Derived: private Base<int> {
   using Base<int>::type;
   using Base<int>::const_type;
   using Base<int>::foo;
 };
 
 void foo() {
   Derived d;
   Derived::type       b = d.foo();
   Derived::const_type c = d.foo();
 }
  ---
 $ g++-3.0 test.C
 test.C: In function `void foo()':
 test.C:18: conversion from `const int' to `int&' discards qualifiers
 
 
 This bug affects all forwarding of overloaded STL container members
 like begin/end/find/...
  
 >Fix:
 A workaround:
 
     forward the members manually in the derived class:
 
 struct Derived: private Base<int> {
   using Base<int>::type;
   using Base<int>::const_type;
   type foo() { return Base<int>::foo(); }
   const_type foo() const { return Base<int>::foo(); }
 };
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]