From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wolfgang Wander To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org Subject: Re: c++/3242: Forwarding using 'using' of base members broken? (see also c++/3283) Date: Wed, 20 Jun 2001 07:16:00 -0000 Message-id: <20010620141605.16847.qmail@sourceware.cygnus.com> X-SW-Source: 2001-06/msg00827.html List-Id: The following reply was made to PR c++/3242; it has been noted by GNATS. From: Wolfgang Wander 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 struct Base { typedef T &type; typedef const T &const_type; type foo(); const_type foo() const; }; struct Derived: private Base { using Base::type; using Base::const_type; using Base::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 { using Base::type; using Base::const_type; type foo() { return Base::foo(); } const_type foo() const { return Base::foo(); } };