public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* EGCS
@ 1999-06-08 11:36 Nilesh Asher
  1999-06-30 23:07 ` EGCS Martin v. Loewis
  0 siblings, 1 reply; 2+ messages in thread
From: Nilesh Asher @ 1999-06-08 11:36 UTC (permalink / raw)
  To: egcs-bugs

I had submitted the following request to GNU on June 2. 
--------------------------------------------------------------------
>From nasher Wed Jun  2 10:41:38 1999
Subject: Help needed.
To: gnu@gnu.org
Date: Wed, 2 Jun 1999 10:41:38 -0700 (PDT)
From: Nilesh Asher <nasher@ichips>
X-Mailer: ELM [version 2.4ME+ PL37 (25)]
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Length: 2145      
Status: RO

Hello there.

I had submitted a request similar to the one given below on your newsgroup 
sometime ago. I was wondering if it was possible for someone to let me know
if a fix for this might be coming sometime. Please do let me know. We have
a lot of code which uses the pattern given below and to workaround it might
be a hassle and a maintenance problem everytime we add a method to one of our
base classes. 

#include <iostream.h>

enum X {
    X_0,
    X_1,
    X_2
};

enum Y {
    Y_0,
    Y_1
};

enum Z {
    Z_0,
    Z_1,
    Z_2
};

class A {
public:
    A() {}
    
    void Print(X x) { cout << "The value of X = " << x << endl; }
    void Print(Y y) { cout << "The value of Y = " << y << endl; }
};

class B : public A {
public:
    B() {}
    // The following solution specified in the C++ Primer, Stanley Lippman 
    // (Third Edition) Page 1054 does not work. Works with our local
    // HP compiler (aCC).
    using A::Print; 

    // If you uncomment the following 2 lines you get the workaround for
    // the problem.
    // virtual void Print(X x) { A::Print(x); }
    // virtual void Print(Y y) { A::Print(y); }
    virtual void Print(Z z) { cout << "The value of Z = " << z << endl; }
};

int
main()
{
    B b;
    
    b.Print(X_1);
    b.Print(Y_0);
    b.Print(Z_2);
    return 0;
}

Expected result:
The value of X = 1
The value of Y = 0
The value of Z = 2

Problems:
types_base_derived.cpp:40: cannot adjust access to `void A::Print(enum X)' in `class B'
types_base_derived.cpp:39:   because of local method `void B::Print(enum Z)' with same name
types_base_derived.cpp: In function `int main()':
types_base_derived.cpp:47: no matching function for call to `B::Print (X)'
types_base_derived.cpp:39: candidates are: B::Print(Z)
types_base_derived.cpp:48: no matching function for call to `B::Print (Y)'
types_base_derived.cpp:39: candidates are: B::Print(Z)

Platform: HP-UX 10.20
Version : gcc/g++ 2.8.1
--------------------------------------------------------------------

I got the following response back.
----- Forwarded message from Project GNU -----

>From gnu@gnu.org  Mon Jun  7 14:24:52 1999
Date: Mon, 7 Jun 1999 17:17:44 -0400
Message-Id: <199906072117.RAA09041@delysid.gnu.org>
From: Project GNU <gnu@gnu.org>
To: nasher@ichips.intel.com
In-reply-to: <199906021741.NAA22283@pdxhp999.pdx.intel.com> (message from
        Nilesh Asher on Wed, 2 Jun 1999 10:41:38 -0700 (PDT))
Subject: Re: Help needed.

The next GCC will be based on EGCS, not GCC 2.8.1.  You might look at
EGCS to see if they have the problem fixed already.  If not, all you 
can do is make suggestions to bug-gcc@gnu.org.

To check out EGCS, go to sourceware.cygnus.com.

-- 
                                   Brian Youmans
                                   FSF Office Staff

Free Software Foundation     |  A 501 (c) 3 not-for-profit
59 Temple Place, Suite 330   |  corporation; contributions
Boston, MA 02111-1307  USA   |  are tax-deductible in the
                             |  USA.
voice: +1-617-542-5942       |
fax:   +1-617-542-2652       |  Support Project GNU...
web:   http://www.gnu.org    |  GNU's Not Unix!

----- End of forwarded message from Project GNU -----

I downloaded the latest (1.12) version of egcs and tried to install it. 
There were a couple of problems and probably still are, but I have something
working. I now get more warnings but the basic problem still remains. 

types_base_derived.cpp:40: cannot adjust access to `void A::Print(enum Y)' in `class B'
types_base_derived.cpp:39:   because of local method `void B::Print(enum Z)' with same name
types_base_derived.cpp: In method `void B::Print(enum Z)':
types_base_derived.cpp:39: warning: passing `Z' chooses `int' over `long unsigned int'
types_base_derived.cpp:39: warning:   in call to `ostream::operator <<(int)'
types_base_derived.cpp:39: warning: passing `Z' chooses `int' over `long int'
types_base_derived.cpp:39: warning:   in call to `ostream::operator <<(int)'
types_base_derived.cpp:39: warning: passing `Z' chooses `int' over `unsigned int'
types_base_derived.cpp:39: warning:   in call to `ostream::operator <<(int)'
types_base_derived.cpp: In function `int main()':
types_base_derived.cpp:47: no matching function for call to `B::Print (X)'
types_base_derived.cpp:39: candidates are: B::Print(Z)
types_base_derived.cpp:48: no matching function for call to `B::Print (Y)'
types_base_derived.cpp:39: candidates are: B::Print(Z)

Can something be done to fix this. Please let me know. I did not see this
in the list of bugs that you have put up on the web page 
http://egcs.cygnus.com/bugs.html , so I am sending it in. Please let me know 
if there is a plan to fix this in gcc 2.95 or when a fix for this can be
available.

Thanks,
-Nilesh.
--
E-mail address  :   nasher@ichips.intel.com
Title           :   Sr. Design Engineer
Phone no.       :   (503) 591-4980
Address         :   Intel Corporation,  5200 N.E.Elam Young Pkwy, M/S AL4-51,
                    Hillsboro, OR 97124.
>From wilson@cygnus.com Tue Jun 08 13:08:00 1999
From: Jim Wilson <wilson@cygnus.com>
To: "Kaveh R. Ghazi" <ghazi@caip.rutgers.edu>
Cc: egcs-bugs@egcs.cygnus.com, egcs-patches@egcs.cygnus.com
Subject: Re: Bootstrap failure on AIX4, alloca missing, (main trunk only) 
Date: Tue, 08 Jun 1999 13:08:00 -0000
Message-id: <199906082008.NAA11225@rtl.cygnus.com>
References: <199906081601.MAA15610@caip.rutgers.edu>
X-SW-Source: 1999-06/msg00200.html
Content-length: 1481

The problem is a typo in my patch.  I checked in the following patch to fix
it.

Tue Jun  8 13:06:15 1999  Jim Wilson  <wilson@cygnus.com>

	* configure.in (rs6000-ibm-aix4.[12]*): Change rx6000 to rs6000.
	* configure: Regenerate.
	
Index: configure.in
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/configure.in,v
retrieving revision 1.253
diff -p -r1.253 configure.in
*** configure.in	1999/06/07 21:38:30	1.253
--- configure.in	1999/06/08 20:06:09
*************** changequote([,])dnl
*** 2931,2937 ****
  		then
  			xmake_file=rs6000/x-aix41-gld
  		else
! 			xmake_file=rx6000/x-aix41
  		fi
  		float_format=none
  		use_collect2=yes
--- 2931,2937 ----
  		then
  			xmake_file=rs6000/x-aix41-gld
  		else
! 			xmake_file=rs6000/x-aix41
  		fi
  		float_format=none
  		use_collect2=yes
Index: configure
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/configure,v
retrieving revision 1.249
diff -p -r1.249 configure
*** configure	1999/06/07 21:38:27	1.249
--- configure	1999/06/08 20:06:09
*************** for machine in $build $host $target; do
*** 5240,5246 ****
  		then
  			xmake_file=rs6000/x-aix41-gld
  		else
! 			xmake_file=rx6000/x-aix41
  		fi
  		float_format=none
  		use_collect2=yes
--- 5240,5246 ----
  		then
  			xmake_file=rs6000/x-aix41-gld
  		else
! 			xmake_file=rs6000/x-aix41
  		fi
  		float_format=none
  		use_collect2=yes
>From eric.freudenthal@nyu.edu Tue Jun 08 13:22:00 1999
From: "Eric Freudenthal" <eric.freudenthal@nyu.edu>
To: <egcs-bugs@egcs.cygnus.com>
Subject: (HELP) internal compiler (egcs c++) error derailing switch to linux
Date: Tue, 08 Jun 1999 13:22:00 -0000
Message-id: <000001beb1eb$6859d060$cd8c7a80@ericl.ultra.nyu.edu>
X-SW-Source: 1999-06/msg00201.html
Content-length: 707

Egcs folk,

I just about convinced our project's leadership to seriously look at
switching to linux (we were using rh5, which uses gcc rather than
egcs, and handled our c and c++ sources fine) when the egcs shipped
with current redhat release (6) derailed my effort by failing with
an internal consistency problem.

 I submitted a bug report including cpp output.  When should someone be able
to look into this problem?

A copy of my bug report is in http://www.rlab.cs.nyu.edu/~freudent/xfer

Thanks, Eric


--
===
Eric Freudenthal http://www.rlab.cs.nyu.edu/~freudent
office:212-998-3345  cell:917-279-6208 (press 2 to send numeric page)
cell pager: freudenthal.pager@eric.ultra.nyu.edu (100 char limit)


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: EGCS
  1999-06-08 11:36 EGCS Nilesh Asher
@ 1999-06-30 23:07 ` Martin v. Loewis
  0 siblings, 0 replies; 2+ messages in thread
From: Martin v. Loewis @ 1999-06-30 23:07 UTC (permalink / raw)
  To: nasher; +Cc: egcs-bugs

> I had submitted a request similar to the one given below on your newsgroup 
> sometime ago. I was wondering if it was possible for someone to let me know
> if a fix for this might be coming sometime. Please do let me know.

Thanks for your report. Please have a look at
http://egcs.cygnus.com/bugs.html

(heading Using declarations in classes do not work). This is an old
bug, and it is unlikely to get fixed anytime soon.

>     // If you uncomment the following 2 lines you get the workaround for
>     // the problem.
>     // virtual void Print(X x) { A::Print(x); }
>     // virtual void Print(Y y) { A::Print(y); }
>     virtual void Print(Z z) { cout << "The value of Z = " << z << endl; }

Meanwhile, the work-around you mention is the best thing you can do.
Please note that you don't have to make the functions virtual. If you
don't, the compiler will inline the calls to the base methods, so you
don't pay any runtime overhead for this work-around - only additional
source code.

Hope this helps,
Martin


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-06-30 23:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-06-08 11:36 EGCS Nilesh Asher
1999-06-30 23:07 ` EGCS Martin v. Loewis

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).