This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c++/142: Re: Anonyous unions prevent proper linking.
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/142: Re: Anonyous unions prevent proper linking.
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Sun, 26 Mar 2000 21:55:19 +0200
- References: <199910200840.BAA17883@teal.ece.ucdavis.edu>
- Resent-Cc: gcc-prs at gcc dot gnu dot org, kenelson at ece dot ucdavis dot edu
- Resent-Reply-To: gcc-gnats@gcc.gnu.org, "Martin v. Loewis" <martin@loewis.home.cs.tu-berlin.de>
>Number: 142
>Category: c++
>Synopsis: Anonyous unions prevent proper linking.
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: analyzed
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Sun Mar 26 12:06:01 PST 2000
>Closed-Date:
>Last-Modified:
>Originator: Karl Nelson <kenelson@ece.ucdavis.edu>
>Release: 2.95.2
>Organization:
>Environment:
>Description:
Original-Message-Id: <199910200840.BAA17883@teal.ece.ucdavis.edu>
Date: Wed, 20 Oct 1999 01:40:16 -0700
Problem description:
If a class is defined within an anonymous union the functions
within contain the index number of the anonymous union within them.
This number in not unique as it it increments for each class. Thus
if a different number of anonymous unions appear functions will not
link.
Affected platforms and versions:
platforms all, version 2.95
Switchs needed to cause error:
None. Default behavior demonstrate error.
Sample: (This must be in 3 seperate files to demonstrate improper
linking,)
--------------------------test.h--------------------------------
struct A
{
union {
void *v;
struct B {
static void foo();
} b;
};
};
--------------------------test1.cc------------------------------
struct C
{
union {
void *i;
int j;
};
};
#include "test.h"
main()
{
A::B::foo();
}
--------------------------test2.cc------------------------------
#include "test.h"
void A::B::foo() {};
----------------------------------------------------------------
compile with: c++ test1.cc test2.cc
Sample Output:
> c++ test1.cc test2.cc
/tmp/ccftbB1R.o: In function `main':
/tmp/ccftbB1R.o(.text+0x7): undefined reference to `A::._1::B::foo(void)'
collect2: ld returned 1 exit status
A::B::foo is properly defined. This should have linked.
--Karl
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: