[gnu.g++.bug] Found compiler hang bug

steveng@GARP.MIT.EDU (Stephen Ng) (04/27/89)

dear gnu,

i found a bug that hangs g++ version 1.34.0.  it is:

int foo();
class C {
        friend int foo();
};

bar()
{
        foo();
}


io get this to work, remove the first declaration of int foo().

i believe our C++ code is correct; the two declarations are not contradictory.

stephen ng

schmidt@zola.ics.uci.edu (Doug Schmidt) (04/28/89)

In article <8904271456.AA18302@lotus.lotus.com> lotus!steveng@GARP.MIT.EDU (Stephen Ng) writes:
++ 
++ dear gnu,
++ 
++ i found a bug that hangs g++ version 1.34.0.  it is:
++ 
++ int foo();
++ class C {
++         friend int foo();
++ };
++ 
++ bar()
++ {
++         foo();
++ }
++ 
++ 

This does not hang with g++ 1.35, although I'm not sure if the message is
correct:

----------------------------------------
g++ bug.c
bug.c:3: friend `foo' implicitly overloaded
bug.c:1: after declaration of non-overloaded `int foo ()'
----------------------------------------

Anyone have any comments?

Doug
--
On a clear day, under blue skies, there is no need to seek.
And asking about Buddha                +------------------------+
Is like proclaiming innocence,         | schmidt@ics.uci.edu    |
With loot in your pocket.              | office: (714) 856-4043 |

tiemann@YAHI.STANFORD.EDU (Michael Tiemann) (05/05/89)

   Date: 28 Apr 89 03:11:39 GMT
   From: schmidt@zola.ics.uci.edu  (Doug Schmidt)
   Organization: University of California at Irvine: ICS Dept.
   References: <8904271456.AA18302@lotus.lotus.com>
   Sender: bug-g++-request@prep.ai.mit.edu

   In article <8904271456.AA18302@lotus.lotus.com> lotus!steveng@GARP.MIT.EDU (Stephen Ng) writes:
   ++ 
   ++ dear gnu,
   ++ 
   ++ i found a bug that hangs g++ version 1.34.0.  it is:
   ++ 
   ++ int foo();
   ++ class C {
   ++         friend int foo();
   ++ };
   ++ 
   ++ bar()
   ++ {
   ++         foo();
   ++ }
   ++ 
   ++ 

   This does not hang with g++ 1.35, although I'm not sure if the message is
   correct:

   ----------------------------------------
   g++ bug.c
   bug.c:3: friend `foo' implicitly overloaded
   bug.c:1: after declaration of non-overloaded `int foo ()'
   ----------------------------------------

   Anyone have any comments?

   Doug
   --
   On a clear day, under blue skies, there is no need to seek.
   And asking about Buddha                +------------------------+
   Is like proclaiming innocence,         | schmidt@ics.uci.edu    |
   With loot in your pocket.              | office: (714) 856-4043 |

Here's the straight rap: in the world of cfront 1.2, one had to
declare a function to be overloaded before one could use it as such.
Thus, if the compiler encountered a declaration for an innocent
function like `foo', it would think that foo had C linkage.  Friends
are implicitly overloaded, which means that calls to friend functions
would be made via the friend's mangled name.  This could lead to
inconsistencies which may or may not show up at link time.  GNU C++
makes sure that this does not happen.

In the world of cfront 2.0, all functions which have C++ linkage are
implicitly overloaded.  Friends or not, calls to these functions go
through mangled names.  Functions which have C linkage go through
unmangled names, overloaded or not (you can't overload a function in
C).

In GNU C++ 1.35.0, the extern "C" and extern "C++" linkage specs will
be recognized, and the 2.0 rules for overloading will apply.  This
means that the code above is no longer considered erroneous.  However,
the debugger will have to be modified to handle this.

Michael