public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/3242: Forwarding using 'using' of base members broken? (see also c++/3283)
@ 2001-06-20  7:16 Wolfgang Wander
  0 siblings, 0 replies; only message in thread
From: Wolfgang Wander @ 2001-06-20  7:16 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

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(); }
 };
 


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-06-20  7:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-20  7:16 c++/3242: Forwarding using 'using' of base members broken? (see also c++/3283) Wolfgang Wander

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).