public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Wolfgang Wander <wwc@rentec.com>
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	[thread overview]
Message-ID: <20010620141605.16847.qmail@sourceware.cygnus.com> (raw)

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


                 reply	other threads:[~2001-06-20  7:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010620141605.16847.qmail@sourceware.cygnus.com \
    --to=wwc@rentec.com \
    --cc=gcc-prs@gcc.gnu.org \
    --cc=nobody@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).