This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/13146] New: inheritance for nonoverlapping_component_refs_p
- From: "dann at godzilla dot ics dot uci dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Nov 2003 22:24:29 -0000
- Subject: [Bug c++/13146] New: inheritance for nonoverlapping_component_refs_p
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Currently g++ cannot tell that accesses to class members from different points
of the inheritance hierachy cannot overlap.
There is a patch that fixes the problem at:
http://gcc.gnu.org/ml/gcc-patches/2002-05/msg01996.html
but it seems that has been forgotten. This bug was created so that the issue
is not completely forgotten.
A testcase is below. It would be nice if a C++ specialist would
add more tests.
/* { dg-do link } */
class first
{
public:
double d;
int f1;
};
class middle : public first
{
};
class second : public middle
{
public:
int f2;
short a;
};
class third
{
public:
char a;
char b;
};
class multi: public third, public second
{
public:
short s;
char f3;
};
extern void link_error ();
void
foo (first *s1, second *s2)
{
s1->f1 = 0;
s2->f2 = 0;
s1->f1++;
s2->f2++;
s1->f1++;
s2->f2++;
if (s1->f1 != 2)
link_error ();
}
void
bar (first *s1, multi *s3)
{
s1->f1 = 0;
s3->f3 = 0;
s1->f1++;
s3->f3++;
s1->f1++;
s3->f3++;
if (s1->f1 != 2)
link_error ();
}
int
main()
{
first a;
second b;
multi c;
foo (&a, &b);
bar (&a, &c);
return 0;
}
--
Summary: inheritance for nonoverlapping_component_refs_p
Product: gcc
Version: 3.4
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dann at godzilla dot ics dot uci dot edu
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13146